From f67d83919eefad4d358b35db6fbf62dfe9761e32 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 4 Oct 2017 14:47:58 -0700 Subject: [PATCH] Keep old mysql login and password if the new ones don't work https://www.virtualmin.com/node/53331 --- mysql/backup_config.pl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mysql/backup_config.pl b/mysql/backup_config.pl index acb188cde..53d4550af 100755 --- a/mysql/backup_config.pl +++ b/mysql/backup_config.pl @@ -26,6 +26,12 @@ return undef; # Called before the files are restored from a backup sub pre_restore { +if (&is_mysql_running() != -1) { + %oldconfig = %config; + } +else { + %oldconfig = ( ); + } return undef; } @@ -33,6 +39,14 @@ return undef; # Called after the files are restored from a backup sub post_restore { +$authstr = &make_authstr(); +&read_file_cached($module_config_file, \%config); +if (&is_mysql_running() == -1 && %oldconfig) { + # New restored login isn't valid .. put back the old one + $config{'login'} = $oldconfig{'login'}; + $config{'pass'} = $oldconfig{'pass'}; + &save_module_config(); + } if (&is_mysql_running()) { &stop_mysql(); return &start_mysql();