From 4f8e79902e6cefa8f434a1026c53ba29ef20de2e Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Mon, 25 Jul 2016 19:46:32 +0100 Subject: [PATCH] Option to reinstall mariadb from control panel --- src/freedombone-controlpanel | 50 ++++++++++++++++++++++++---------- src/freedombone-utils-database | 7 +++++ 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/src/freedombone-controlpanel b/src/freedombone-controlpanel index a36d048a..17ded6bf 100755 --- a/src/freedombone-controlpanel +++ b/src/freedombone-controlpanel @@ -1783,6 +1783,24 @@ function hotspot_settings { --msgbox $"Hotspot settings were changed" 6 40 } +function reinstall_mariadb { + dialog --title $"Reinstall MariaDB" \ + --backtitle $"Freedombone Control Panel" \ + --defaultno \ + --yesno $"\nThis should be a LAST RESORT, if the mysql daemon won't start. You will lose ALL databases and will then need to restore them from backup.\n\nAre you sure that you wish to continue?" 12 60 + sel=$? + case $sel in + 1) return;; + 255) return;; + esac + + clear + database_reinstall + + dialog --title $"Reinstall MariaDB" \ + --msgbox $"MariaDB has been reinstalled" 6 40 +} + function menu_backup_restore { while true do @@ -1790,17 +1808,18 @@ function menu_backup_restore { trap "rm -f $data" 0 1 2 5 15 dialog --backtitle $"Freedombone Control Panel" \ --title $"Backup and Restore" \ - --radiolist $"Choose an operation:" 18 70 11 \ + --radiolist $"Choose an operation:" 19 70 12 \ 1 $"Backup data to USB drive" off \ 2 $"Restore GPG key from USB keydrive" off \ 3 $"Restore data from USB drive" off \ - 4 $"Configure remote backups" off \ - 5 $"Restore from remote backup" off \ - 6 $"Backup GPG key to USB (master keydrive)" off \ - 7 $"Backup GPG key to USB (fragment keydrive)" off \ - 8 $"Format a USB drive (LUKS encrypted)" off \ - 9 $"Remove backups from a USB drive" off \ - 10 $"Back to main menu" on 2> $data + 4 $"Reinstall mariadb" off \ + 5 $"Configure remote backups" off \ + 6 $"Restore from remote backup" off \ + 7 $"Backup GPG key to USB (master keydrive)" off \ + 8 $"Backup GPG key to USB (fragment keydrive)" off \ + 9 $"Format a USB drive (LUKS encrypted)" off \ + 10 $"Remove backups from a USB drive" off \ + 11 $"Back to main menu" on 2> $data sel=$? case $sel in 1) break;; @@ -1810,13 +1829,14 @@ function menu_backup_restore { 1) backup_data;; 2) restore_gpg_key;; 3) restore_data;; - 4) configure_remote_backups;; - 5) restore_data_remote;; - 6) create_keydrive_master;; - 7) create_keydrive_fragment;; - 8) format_drive;; - 9) remove_backups;; - 10) break;; + 4) reinstall_mariadb;; + 5) configure_remote_backups;; + 6) restore_data_remote;; + 7) create_keydrive_master;; + 8) create_keydrive_fragment;; + 9) format_drive;; + 10) remove_backups;; + 11) break;; esac done } diff --git a/src/freedombone-utils-database b/src/freedombone-utils-database index ef4c5597..55153f08 100755 --- a/src/freedombone-utils-database +++ b/src/freedombone-utils-database @@ -327,4 +327,11 @@ function drop_database { mysqladmin -uroot -p"$MARIADB_PASSWORD" -f drop $database_name } +function database_reinstall { + apt-get -y purge mariadb* + rm -rf /var/lib/mysql + rm -rf /etc/mysql + apt-get -y install mariadb-server +} + # NOTE: deliberately there is no "exit 0"