Rescue from failed database reset

This commit is contained in:
Brendan Coles
2019-02-10 08:45:36 +00:00
parent ee68811e62
commit cb2e8b6681

21
beef
View File

@@ -129,13 +129,22 @@ case config.get("beef.database.driver")
end
#
# @note Resets the database if the -x flag was passed
# @note Load the database
#
if BeEF::Core::Console::CommandLine.parse[:resetdb]
print_info 'Resetting the database for BeEF.'
DataMapper.auto_migrate!
else
DataMapper.auto_upgrade!
begin
# @note Resets the database if the -x flag was passed
if BeEF::Core::Console::CommandLine.parse[:resetdb]
print_info 'Resetting the database for BeEF.'
DataMapper.auto_migrate!
else
DataMapper.auto_upgrade!
end
rescue => e
print_error "Could not connect to database: #{e.message}"
if config.get("beef.database.driver") == 'sqlite'
print_more "Ensure the #{config.get("beef.database.db_file")} database file is writable"
end
exit 1
end
#