Skip to content

Commit 1f5ce84

Browse files
committed
Add status_db function
1 parent 8c7224f commit 1f5ce84

File tree

1 file changed

+16
-1
lines changed
  • config/templates/metasploit-framework-wrappers

1 file changed

+16
-1
lines changed

config/templates/metasploit-framework-wrappers/msfdb.erb

+16-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ def tail(file)
2828
File.readlines(file).last.to_s.strip
2929
end
3030

31+
def status_db
32+
if Dir.exist?(@db)
33+
if system("#{@pg_ctl} -o \"-p #{@dbport}\" -D #{@db} status > /dev/null")
34+
puts "Database started at #{@db}"
35+
else
36+
puts "Database is not running at #{@db}"
37+
end
38+
else
39+
puts "No database found at #{@db}"
40+
end
41+
end
42+
3143
def start_db
3244
if Dir.exist?(@db)
3345
if system("#{@pg_ctl} -o \"-p #{@dbport}\" -D #{@db} status > /dev/null")
@@ -36,7 +48,7 @@ def start_db
3648
puts "Starting database at #{@db}"
3749
system("#{@pg_ctl} -o \"-p #{@dbport}\" -D #{@db} -l #{@db}/log start > /dev/null")
3850
sleep(2)
39-
unless system("#{@pg_ctl} -D #{@db} status > /dev/null")
51+
unless system("#{@pg_ctl} -o \"-p #{@dbport}\" -D #{@db} status > /dev/null")
4052
print 'The database failed to start: '
4153
puts tail("#{@db}/log")
4254
loop do
@@ -190,6 +202,7 @@ Manage a metasploit framework database
190202
#{prog} init # initialize the database
191203
#{prog} reinit # delete and reinitialize the database
192204
#{prog} delete # delete database and stop using it
205+
#{prog} status # check database status
193206
#{prog} start # start the database
194207
#{prog} stop # stop the database
195208
@@ -208,6 +221,8 @@ when 'reinit'
208221
reinit_db
209222
when 'delete'
210223
delete_db
224+
when 'status'
225+
status_db
211226
when 'start'
212227
start_db
213228
when 'stop'

0 commit comments

Comments
 (0)