Browse Source

Option to reinstall mariadb from control panel

Bob Mottram 8 years ago
parent
commit
4f8e79902e
2 changed files with 42 additions and 15 deletions
  1. 35
    15
      src/freedombone-controlpanel
  2. 7
    0
      src/freedombone-utils-database

+ 35
- 15
src/freedombone-controlpanel View File

@@ -1783,6 +1783,24 @@ function hotspot_settings {
1783 1783
 		   --msgbox $"Hotspot settings were changed" 6 40
1784 1784
 }
1785 1785
 
1786
+function reinstall_mariadb {
1787
+	dialog --title $"Reinstall MariaDB" \
1788
+		   --backtitle $"Freedombone Control Panel" \
1789
+		   --defaultno \
1790
+		   --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
1791
+	sel=$?
1792
+	case $sel in
1793
+		1) return;;
1794
+		255) return;;
1795
+	esac
1796
+
1797
+	clear
1798
+	database_reinstall
1799
+
1800
+	dialog --title $"Reinstall MariaDB" \
1801
+		   --msgbox $"MariaDB has been reinstalled" 6 40
1802
+}
1803
+
1786 1804
 function menu_backup_restore {
1787 1805
 	while true
1788 1806
 	do
@@ -1790,17 +1808,18 @@ function menu_backup_restore {
1790 1808
 		trap "rm -f $data" 0 1 2 5 15
1791 1809
 		dialog --backtitle $"Freedombone Control Panel" \
1792 1810
 			   --title $"Backup and Restore" \
1793
-			   --radiolist $"Choose an operation:" 18 70 11 \
1811
+			   --radiolist $"Choose an operation:" 19 70 12 \
1794 1812
 			   1 $"Backup data to USB drive" off \
1795 1813
 			   2 $"Restore GPG key from USB keydrive" off \
1796 1814
 			   3 $"Restore data from USB drive" off \
1797
-			   4 $"Configure remote backups" off \
1798
-			   5 $"Restore from remote backup" off \
1799
-			   6 $"Backup GPG key to USB (master keydrive)" off \
1800
-			   7 $"Backup GPG key to USB (fragment keydrive)" off \
1801
-			   8 $"Format a USB drive (LUKS encrypted)" off \
1802
-			   9 $"Remove backups from a USB drive" off \
1803
-			   10 $"Back to main menu" on 2> $data
1815
+			   4 $"Reinstall mariadb" off \
1816
+			   5 $"Configure remote backups" off \
1817
+			   6 $"Restore from remote backup" off \
1818
+			   7 $"Backup GPG key to USB (master keydrive)" off \
1819
+			   8 $"Backup GPG key to USB (fragment keydrive)" off \
1820
+			   9 $"Format a USB drive (LUKS encrypted)" off \
1821
+			   10 $"Remove backups from a USB drive" off \
1822
+			   11 $"Back to main menu" on 2> $data
1804 1823
 		sel=$?
1805 1824
 		case $sel in
1806 1825
 			1) break;;
@@ -1810,13 +1829,14 @@ function menu_backup_restore {
1810 1829
 			1) backup_data;;
1811 1830
 			2) restore_gpg_key;;
1812 1831
 			3) restore_data;;
1813
-			4) configure_remote_backups;;
1814
-			5) restore_data_remote;;
1815
-			6) create_keydrive_master;;
1816
-			7) create_keydrive_fragment;;
1817
-			8) format_drive;;
1818
-			9) remove_backups;;
1819
-			10) break;;
1832
+			4) reinstall_mariadb;;
1833
+			5) configure_remote_backups;;
1834
+			6) restore_data_remote;;
1835
+			7) create_keydrive_master;;
1836
+			8) create_keydrive_fragment;;
1837
+			9) format_drive;;
1838
+			10) remove_backups;;
1839
+			11) break;;
1820 1840
 		esac
1821 1841
 	done
1822 1842
 }

+ 7
- 0
src/freedombone-utils-database View File

@@ -327,4 +327,11 @@ function drop_database {
327 327
 	mysqladmin -uroot -p"$MARIADB_PASSWORD" -f drop $database_name
328 328
 }
329 329
 
330
+function database_reinstall {
331
+	apt-get -y purge mariadb*
332
+	rm -rf /var/lib/mysql
333
+	rm -rf /etc/mysql
334
+	apt-get -y install mariadb-server
335
+}
336
+
330 337
 # NOTE: deliberately there is no "exit 0"