Ver código fonte

Add drive formatting to the control panel

Bob Mottram 9 anos atrás
pai
commit
34be8d1c04
1 arquivos alterados com 46 adições e 3 exclusões
  1. 46
    3
      src/freedombone-controlpanel

+ 46
- 3
src/freedombone-controlpanel Ver arquivo

@@ -549,6 +549,47 @@ function hubzilla_channel_directory_server {
549 549
     esac       
550 550
 }
551 551
 
552
+function format_drive {
553
+    drive=
554
+    
555
+    data=$(tempfile 2>/dev/null)
556
+    trap "rm -f $data" 0 1 2 5 15
557
+    dialog --backtitle "Freedombone Control Panel" \
558
+           --title "Format a USB drive" \
559
+           --radiolist "Choose a drive:" 14 70 5 \
560
+           1 "sda (Beaglebone Black)" off \
561
+           2 "sdb" off \
562
+           3 "sdc" off \
563
+           4 "sdd" off \
564
+           5 "Back to Backup and Restore menu" on 2> $data
565
+    sel=$?
566
+    case $sel in
567
+        1) return;;
568
+        255) return;;
569
+    esac
570
+    case $(cat $data) in
571
+        1) drive='sda';;
572
+        2) drive='sdb';;
573
+        3) drive='sdc';;
574
+        4) drive='sdd';;
575
+        5) return;;
576
+    esac
577
+
578
+    dialog --title "Format USB drive" \
579
+           --backtitle "Freedombone Control Panel" \
580
+           --defaultno \
581
+           --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
582
+    sel=$?
583
+    case $sel in
584
+        1) return;;
585
+        255) return;;
586
+    esac
587
+
588
+    clear
589
+    freedombone-format $drive
590
+    any_key
591
+}
592
+
552 593
 function menu_backup_restore {
553 594
     while true
554 595
     do
@@ -556,7 +597,7 @@ function menu_backup_restore {
556 597
         trap "rm -f $data" 0 1 2 5 15
557 598
         dialog --backtitle "Freedombone Control Panel" \
558 599
                --title "Backup and Restore" \
559
-               --radiolist "Choose an operation:" 15 70 8 \
600
+               --radiolist "Choose an operation:" 16 70 9 \
560 601
                1 "Backup data to USB drive" off \
561 602
                2 "Restore GPG key from USB keydrive" off \
562 603
                3 "Restore data from USB drive" off \
@@ -564,7 +605,8 @@ function menu_backup_restore {
564 605
                5 "Restore from remote backup" off \
565 606
                6 "Backup GPG key to USB (master keydrive)" off \
566 607
                7 "Backup GPG key to USB (fragment keydrive)" off \
567
-               8 "Back to main menu" on 2> $data
608
+               8 "Format a USB drive" off \
609
+               9 "Back to main menu" on 2> $data
568 610
         sel=$?
569 611
         case $sel in
570 612
             1) break;;
@@ -578,7 +620,8 @@ function menu_backup_restore {
578 620
             5) restore_data_remote;;
579 621
             6) create_keydrive_master;;
580 622
             7) create_keydrive_fragment;;
581
-            8) break;;
623
+            7) format_drive;;
624
+            9) break;;
582 625
         esac
583 626
     done
584 627
 }