From cb2e8b66818914828937f8df9c79c4759e5033d0 Mon Sep 17 00:00:00 2001 From: Brendan Coles Date: Sun, 10 Feb 2019 08:45:36 +0000 Subject: [PATCH] Rescue from failed database reset --- beef | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/beef b/beef index cb15e28fe..77e2c831c 100755 --- a/beef +++ b/beef @@ -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 #