浏览代码

Add drive formatting to the control panel

Bob Mottram 9 年前
父节点
当前提交
34be8d1c04
共有 1 个文件被更改,包括 46 次插入3 次删除
  1. 46
    3
      src/freedombone-controlpanel

+ 46
- 3
src/freedombone-controlpanel 查看文件

549
     esac       
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
 function menu_backup_restore {
593
 function menu_backup_restore {
553
     while true
594
     while true
554
     do
595
     do
556
         trap "rm -f $data" 0 1 2 5 15
597
         trap "rm -f $data" 0 1 2 5 15
557
         dialog --backtitle "Freedombone Control Panel" \
598
         dialog --backtitle "Freedombone Control Panel" \
558
                --title "Backup and Restore" \
599
                --title "Backup and Restore" \
559
-               --radiolist "Choose an operation:" 15 70 8 \
600
+               --radiolist "Choose an operation:" 16 70 9 \
560
                1 "Backup data to USB drive" off \
601
                1 "Backup data to USB drive" off \
561
                2 "Restore GPG key from USB keydrive" off \
602
                2 "Restore GPG key from USB keydrive" off \
562
                3 "Restore data from USB drive" off \
603
                3 "Restore data from USB drive" off \
564
                5 "Restore from remote backup" off \
605
                5 "Restore from remote backup" off \
565
                6 "Backup GPG key to USB (master keydrive)" off \
606
                6 "Backup GPG key to USB (master keydrive)" off \
566
                7 "Backup GPG key to USB (fragment keydrive)" off \
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
         sel=$?
610
         sel=$?
569
         case $sel in
611
         case $sel in
570
             1) break;;
612
             1) break;;
578
             5) restore_data_remote;;
620
             5) restore_data_remote;;
579
             6) create_keydrive_master;;
621
             6) create_keydrive_master;;
580
             7) create_keydrive_fragment;;
622
             7) create_keydrive_fragment;;
581
-            8) break;;
623
+            7) format_drive;;
624
+            9) break;;
582
         esac
625
         esac
583
     done
626
     done
584
 }
627
 }