Skip prompts with new use-defaults option
parent
9ecc4b9d1c
commit
0bd21e9ba1
17
msfdb
17
msfdb
|
@ -66,6 +66,7 @@ require 'msf/util/helper'
|
|||
retry_max: 10,
|
||||
retry_delay: 5.0,
|
||||
ws_user: nil,
|
||||
use_defaults: false,
|
||||
delete_existing_data: nil
|
||||
}
|
||||
|
||||
|
@ -190,7 +191,7 @@ def start_db
|
|||
if last_log =~ /not compatible/
|
||||
puts 'Please attempt to upgrade the database manually using pg_upgrade.'
|
||||
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
|
||||
|
||||
|
@ -458,13 +459,17 @@ def init_web_service
|
|||
return false
|
||||
end
|
||||
|
||||
unless @options[:use_defaults]
|
||||
if @options[:ws_user].nil?
|
||||
@msf_ws_user = ask_value('Initial MSF web service account username?', @msf_ws_user)
|
||||
else
|
||||
@msf_ws_user = @options[:ws_user]
|
||||
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)')
|
||||
else
|
||||
@msf_ws_pass = @options[:ws_pass]
|
||||
|
@ -688,9 +693,9 @@ def output_web_service_information
|
|||
end
|
||||
|
||||
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 = 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
|
||||
connect_cmd = get_db_connect_command(name: data_service_name)
|
||||
cmd = "msfconsole -qx \"#{connect_cmd}; db_save; exit\""
|
||||
|
@ -845,6 +850,9 @@ def parse_args(args)
|
|||
puts opts
|
||||
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('Database Options:')
|
||||
|
@ -997,6 +1005,7 @@ end
|
|||
|
||||
|
||||
def should_delete
|
||||
return true if @options[:use_defaults]
|
||||
ask_yn("Would you like to delete your existing data and configurations?")
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue