Skip prompts with new use-defaults option
This commit is contained in:
parent
9ecc4b9d1c
commit
0bd21e9ba1
25
msfdb
25
msfdb
|
@ -66,6 +66,7 @@ require 'msf/util/helper'
|
||||||
retry_max: 10,
|
retry_max: 10,
|
||||||
retry_delay: 5.0,
|
retry_delay: 5.0,
|
||||||
ws_user: nil,
|
ws_user: nil,
|
||||||
|
use_defaults: false,
|
||||||
delete_existing_data: nil
|
delete_existing_data: nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +191,7 @@ def start_db
|
||||||
if last_log =~ /not compatible/
|
if last_log =~ /not compatible/
|
||||||
puts 'Please attempt to upgrade the database manually using pg_upgrade.'
|
puts 'Please attempt to upgrade the database manually using pg_upgrade.'
|
||||||
end
|
end
|
||||||
print_error "Your database may be corrupt. Try reinitializing by running #{'msfdb reinit --component database'.underline}."
|
print_error "Your database may be corrupt. Try reinitializing."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -458,13 +459,17 @@ def init_web_service
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
if @options[:ws_user].nil?
|
unless @options[:use_defaults]
|
||||||
@msf_ws_user = ask_value('Initial MSF web service account username?', @msf_ws_user)
|
if @options[:ws_user].nil?
|
||||||
else
|
@msf_ws_user = ask_value('Initial MSF web service account username?', @msf_ws_user)
|
||||||
@msf_ws_user = @options[:ws_user]
|
else
|
||||||
|
@msf_ws_user = @options[:ws_user]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if @options[:ws_pass].nil?
|
if @options[:use_defaults]
|
||||||
|
@msf_ws_pass = pw_gen
|
||||||
|
elsif @options[:ws_pass].nil?
|
||||||
@msf_ws_pass = ask_password('Initial MSF web service account password? (Leave blank for random password)')
|
@msf_ws_pass = ask_password('Initial MSF web service account password? (Leave blank for random password)')
|
||||||
else
|
else
|
||||||
@msf_ws_pass = @options[:ws_pass]
|
@msf_ws_pass = @options[:ws_pass]
|
||||||
|
@ -688,9 +693,9 @@ def output_web_service_information
|
||||||
end
|
end
|
||||||
|
|
||||||
def persist_data_service
|
def persist_data_service
|
||||||
if ask_yn('Add data service connection to local msfconsole and persist as default?')
|
if @options[:use_defaults] || ask_yn('Add data service connection to local msfconsole and persist as default?')
|
||||||
data_service_name = "local-#{@options[:ssl] ? 'https' : 'http'}-data-service"
|
data_service_name = "local-#{@options[:ssl] ? 'https' : 'http'}-data-service"
|
||||||
data_service_name = ask_value('Data service connection name?', data_service_name)
|
data_service_name = ask_value('Data service connection name?', data_service_name) unless @options[:use_defaults]
|
||||||
# execute msfconsole commands to add and persist the data service connection
|
# execute msfconsole commands to add and persist the data service connection
|
||||||
connect_cmd = get_db_connect_command(name: data_service_name)
|
connect_cmd = get_db_connect_command(name: data_service_name)
|
||||||
cmd = "msfconsole -qx \"#{connect_cmd}; db_save; exit\""
|
cmd = "msfconsole -qx \"#{connect_cmd}; db_save; exit\""
|
||||||
|
@ -845,6 +850,9 @@ def parse_args(args)
|
||||||
puts opts
|
puts opts
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
opts.on('--use-defaults', 'Accept all defaults and do not prompt for options during an init') { |d|
|
||||||
|
@options[:use_defaults] = d
|
||||||
|
}
|
||||||
|
|
||||||
opts.separator('')
|
opts.separator('')
|
||||||
opts.separator('Database Options:')
|
opts.separator('Database Options:')
|
||||||
|
@ -997,6 +1005,7 @@ end
|
||||||
|
|
||||||
|
|
||||||
def should_delete
|
def should_delete
|
||||||
|
return true if @options[:use_defaults]
|
||||||
ask_yn("Would you like to delete your existing data and configurations?")
|
ask_yn("Would you like to delete your existing data and configurations?")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue