Allow a database config file to be specified
git-svn-id: file:///home/svn/framework3/trunk@10743 4d416f70-5f16-0410-b530-b9f4589650daunstable
parent
ff7162aa2e
commit
f5f7f555b0
|
@ -147,6 +147,22 @@ class Driver < Msf::Ui::Driver
|
||||||
if @defanged
|
if @defanged
|
||||||
self.command_passthru = false
|
self.command_passthru = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Parse any specified database.yml file
|
||||||
|
if framework.db.usable and opts['DatabaseYAML']
|
||||||
|
dbinfo = YAML.load(File.read(opts['DatabaseYAML']))
|
||||||
|
dbenv = opts['DatabaseEnv'] || "production"
|
||||||
|
db = dbinfo[dbenv]
|
||||||
|
|
||||||
|
if not db
|
||||||
|
print_error("No database definition for environment #{dbenv}")
|
||||||
|
else
|
||||||
|
if not framework.db.connect(db)
|
||||||
|
print_error("Failed to connect to the database: #{framework.db.error} #{db.inspect} #{framework.db.error.backtrace}")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# Process things before we actually display the prompt and get rocking
|
# Process things before we actually display the prompt and get rocking
|
||||||
on_startup
|
on_startup
|
||||||
|
|
|
@ -54,6 +54,14 @@ class OptsConsole
|
||||||
options['ModulePath'] = m
|
options['ModulePath'] = m
|
||||||
end
|
end
|
||||||
|
|
||||||
|
opts.on("-y", "--yaml <database.yml>", "Specify a YAML file containing database settings") do |m|
|
||||||
|
options['DatabaseYAML'] = m
|
||||||
|
end
|
||||||
|
|
||||||
|
opts.on("-e", "--environment <production|development>", "Specify the database environment to load from the YAML") do |m|
|
||||||
|
options['DatabaseEnv'] = m
|
||||||
|
end
|
||||||
|
|
||||||
# Boolean switch.
|
# Boolean switch.
|
||||||
opts.on("-v", "--version", "Show version") do |v|
|
opts.on("-v", "--version", "Show version") do |v|
|
||||||
options['Version'] = true
|
options['Version'] = true
|
||||||
|
|
Loading…
Reference in New Issue