Add drive formatting to the control panel

This commit is contained in:
Bob Mottram 2015-11-05 09:22:39 +00:00
parent b28fd25db8
commit 34be8d1c04
1 changed files with 46 additions and 3 deletions

View File

@ -549,6 +549,47 @@ function hubzilla_channel_directory_server {
esac esac
} }
function format_drive {
drive=
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Control Panel" \
--title "Format a USB drive" \
--radiolist "Choose a drive:" 14 70 5 \
1 "sda (Beaglebone Black)" off \
2 "sdb" off \
3 "sdc" off \
4 "sdd" off \
5 "Back to Backup and Restore menu" on 2> $data
sel=$?
case $sel in
1) return;;
255) return;;
esac
case $(cat $data) in
1) drive='sda';;
2) drive='sdb';;
3) drive='sdc';;
4) drive='sdd';;
5) return;;
esac
dialog --title "Format USB drive" \
--backtitle "Freedombone Control Panel" \
--defaultno \
--yesno "\nPlease confirm that you wish to format drive\n\n${drive}\n\n. All current data on the drive will be lost, and you will be prompted to give a password used to encrypt the drive.\n\nIf you screw up here and format the wrong drive it's your own fault!" 10 60
sel=$?
case $sel in
1) return;;
255) return;;
esac
clear
freedombone-format $drive
any_key
}
function menu_backup_restore { function menu_backup_restore {
while true while true
do do
@ -556,7 +597,7 @@ function menu_backup_restore {
trap "rm -f $data" 0 1 2 5 15 trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Control Panel" \ dialog --backtitle "Freedombone Control Panel" \
--title "Backup and Restore" \ --title "Backup and Restore" \
--radiolist "Choose an operation:" 15 70 8 \ --radiolist "Choose an operation:" 16 70 9 \
1 "Backup data to USB drive" off \ 1 "Backup data to USB drive" off \
2 "Restore GPG key from USB keydrive" off \ 2 "Restore GPG key from USB keydrive" off \
3 "Restore data from USB drive" off \ 3 "Restore data from USB drive" off \
@ -564,7 +605,8 @@ function menu_backup_restore {
5 "Restore from remote backup" off \ 5 "Restore from remote backup" off \
6 "Backup GPG key to USB (master keydrive)" off \ 6 "Backup GPG key to USB (master keydrive)" off \
7 "Backup GPG key to USB (fragment keydrive)" off \ 7 "Backup GPG key to USB (fragment keydrive)" off \
8 "Back to main menu" on 2> $data 8 "Format a USB drive" off \
9 "Back to main menu" on 2> $data
sel=$? sel=$?
case $sel in case $sel in
1) break;; 1) break;;
@ -578,7 +620,8 @@ function menu_backup_restore {
5) restore_data_remote;; 5) restore_data_remote;;
6) create_keydrive_master;; 6) create_keydrive_master;;
7) create_keydrive_fragment;; 7) create_keydrive_fragment;;
8) break;; 7) format_drive;;
9) break;;
esac esac
done done
} }