remove _db suffix

This commit is contained in:
dwelch-r7
2021-04-20 14:02:34 +01:00
parent ee7ad8cef3
commit e5efcc5f3b
4 changed files with 38 additions and 36 deletions
+7 -7
View File
@@ -1,30 +1,30 @@
class DbInterface
def init_db
def init
raise NotImplementedError
end
def delete_db
def delete
raise NotImplementedError
end
def reinit_db
def reinit
raise NotImplementedError
end
def start_db
def start
raise NotImplementedError
end
def stop_db
def stop
raise NotImplementedError
end
def restart_db
def restart
raise NotImplementedError
end
def status_db
def status
raise NotImplementedError
end
+12 -12
View File
@@ -10,7 +10,7 @@ class PgCtl < DbInterface
super()
end
def init_db
def init
puts "Creating database at #{@db}"
Dir.mkdir(@db)
run_cmd("initdb --auth-host=trust --auth-local=trust -E UTF8 #{@db}")
@@ -20,9 +20,9 @@ class PgCtl < DbInterface
end
end
def delete_db
def delete
if Dir.exist?(@db)
stop_db
stop
if @options[:delete_existing_data]
puts "Deleting all data at #{@db}"
@@ -37,12 +37,12 @@ class PgCtl < DbInterface
end
end
def reinit_db
delete_db
init_db
def reinit
delete
init
end
def start_db
def start
if run_cmd("pg_ctl -o \"-p #{@options[:db_port]}\" -D #{@db} status") == 0
puts "Database already started at #{@db}"
return true
@@ -60,7 +60,7 @@ class PgCtl < DbInterface
end
end
def stop_db
def stop
if run_cmd("pg_ctl -o \"-p #{@options[:db_port]}\" -D #{@db} status") == 0
puts "Stopping database at #{@db}"
run_cmd("pg_ctl -o \"-p #{@options[:db_port]}\" -D #{@db} stop")
@@ -69,12 +69,12 @@ class PgCtl < DbInterface
end
end
def restart_db
stop_db
start_db
def restart
stop
start
end
def status_db
def status
if Dir.exist?(@db)
if run_cmd("pg_ctl -o \"-p #{@options[:db_port]}\" -D #{@db} status") == 0
puts "Database started at #{@db}"
+10 -10
View File
@@ -13,7 +13,7 @@ class PgCtlcluster < DbInterface
super()
end
def init_db
def init
puts "Creating database at #{@db}"
Dir.mkdir(@db)
FileUtils.mkdir_p(@pg_cluster_conf_root)
@@ -23,9 +23,9 @@ class PgCtlcluster < DbInterface
end
end
def delete_db
def delete
if Dir.exist?(@db)
stop_db
stop
if @options[:delete_existing_data]
puts "Deleting all data at #{@db}"
@@ -39,12 +39,12 @@ class PgCtlcluster < DbInterface
end
end
def reinit_db
delete_db
init_db
def reinit
delete
init
end
def start_db
def start
print "Starting database at #{@db}..."
status = run_cmd("pg_ctlcluster #{@pg_version} #{@options[:msf_db_name]} start -- -o \"-p #{@options[:db_port]}\" -D #{@db} -l #{@db}/log")
case status
@@ -60,15 +60,15 @@ class PgCtlcluster < DbInterface
end
end
def stop_db
def stop
run_cmd("pg_ctlcluster #{get_postgres_version} #{@options[:msf_db_name]} stop -- -o \"-p #{@options[:db_port]}\" -D #{@db}")
end
def restart_db
def restart
run_cmd("pg_ctlcluster #{@pg_version} #{@options[:msf_db_name]} reload -- -o \"-p #{@options[:db_port]}\" -D #{@db} -l #{@db}/log")
end
def status_db
def status
if Dir.exist?(@db)
if run_cmd("pg_ctlcluster #{@pg_version} #{@options[:msf_db_name]} status -- -o \"-p #{@options[:db_port]}\" -D #{@db}") == 0
puts "Database started at #{@db}"
+9 -7
View File
@@ -160,11 +160,11 @@ end
def status_db
update_db_port
@db_driver.status_db
@db_driver.status
end
def started_db
@db_driver.start_db
@db_driver.start
end
def start_db
@@ -188,15 +188,15 @@ end
def stop_db
update_db_port
@db_driver.stop_db
@db_driver.stop
end
def restart_db
@db_driver.restart_db
@db_driver.restart
end
def create_db
@db_driver.init_db
@db_driver.init
end
def create_db_users
@@ -236,7 +236,7 @@ def init_db
create_db_users
@db_driver.write_db_client_auth_config
@db_driver.restart_db
@db_driver.restart
puts 'Creating initial database schema'
Dir.chdir(@framework) do
@@ -363,7 +363,7 @@ def print_error(error)
end
def delete_db
@db_driver.delete_db
@db_driver.delete
end
def reinit_db
@@ -1019,8 +1019,10 @@ if $PROGRAM_NAME == __FILE__
end
if installed?("pg_ctl") && has_requirements(PgCtl.requirements)
puts "herehere"
@db_driver = PgCtl.new(db_path: @db, options: @options, localconf: @localconf, db_conf: @db_conf)
elsif installed?("pg_ctlcluster") && has_requirements(PgCtlcluster.requirements)
puts "herehere2222"
@db_driver = PgCtlcluster.new(db_path: @db, options: @options, localconf: @localconf, db_conf: @db_conf)
else
abort