Skip to content

Commit

Permalink
Land #24, msfdb run_cmd fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wvu committed Sep 16, 2015
2 parents a4002c0 + 0b04c76 commit dfda7c7
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions config/templates/metasploit-framework/msfdb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ end
@pg_ctl = "#{@bin}/pg_ctl"

def run_cmd(cmd)
exit_status = 0
exitstatus = 0

Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|
exit_status = wait_thr.value
exitstatus = wait_thr.value.exitstatus
end

exit_status
exitstatus
end

def run_psql(cmd)
Expand All @@ -45,7 +45,7 @@ end

def status_db
if Dir.exist?(@db)
if !run_cmd("#{@pg_ctl} -o \"-p #{@dbport}\" -D #{@db} status").nil?
if run_cmd("#{@pg_ctl} -o \"-p #{@dbport}\" -D #{@db} status") == 0
puts "Database started at #{@db}"
else
puts "Database is not running at #{@db}"
Expand All @@ -57,7 +57,7 @@ end

def start_db
if Dir.exist?(@db)
if run_cmd("#{@pg_ctl} -o \"-p #{@dbport}\" -D #{@db} status")
if run_cmd("#{@pg_ctl} -o \"-p #{@dbport}\" -D #{@db} status") == 0
puts "Database already started at #{@db}"
else
puts "Starting database at #{@db}"
Expand Down Expand Up @@ -87,7 +87,7 @@ def start_db
end

def stop_db
if run_cmd("#{@pg_ctl} -o \"-p #{@dbport}\" -D #{@db} status")
if run_cmd("#{@pg_ctl} -o \"-p #{@dbport}\" -D #{@db} status") == 0
puts "Stopping database at #{@db}"
run_cmd("#{@pg_ctl} -o \"-p #{@dbport}\" -D #{@db} stop")
else
Expand Down

0 comments on commit dfda7c7

Please sign in to comment.