Quellcode durchsuchen

Choose an application to restore

Bob Mottram vor 9 Jahren
Ursprung
Commit
315423a88e
1 geänderte Dateien mit 88 neuen und 2 gelöschten Zeilen
  1. 88
    2
      src/freedombone-controlpanel

+ 88
- 2
src/freedombone-controlpanel Datei anzeigen

@@ -40,6 +40,18 @@ ADMIN_USER=
40 40
 UPGRADE_SCRIPT_NAME="${PROJECT_NAME}-upgrade"
41 41
 UPDATE_DATE_SCRIPT=/usr/bin/updatedate
42 42
 
43
+USB_DRIVE=sdb
44
+# get default USB from config file
45
+CONFIG_FILE=$HOME/${PROJECT_NAME}.cfg
46
+if [ -f $CONFIG_FILE ]; then
47
+    if grep -q "USB_DRIVE=" $CONFIG_FILE; then
48
+        USB_DRIVE=$(cat $CONFIG_FILE | grep "USB_DRIVE=" | awk -F '=' '{print $2}')
49
+        if [[ $USB_DRIVE == *"dev"* ]]; then
50
+            USB_DRIVE=$(echo ${USB_DRIVE} | awk -F '/' '{print $3}' | sed 's|1||g' | sed 's|2||g')
51
+        fi
52
+    fi
53
+fi
54
+
43 55
 function any_key {
44 56
     echo ' '
45 57
     read -n1 -r -p $"Press any key to continue..." key
@@ -469,14 +481,88 @@ function backup_data {
469 481
     any_key
470 482
 }
471 483
 
484
+function restore_from_usb {
485
+    while true
486
+    do
487
+        data=$(tempfile 2>/dev/null)
488
+        trap "rm -f $data" 0 1 2 5 15
489
+        dialog --backtitle $"Freedombone Control Panel" \
490
+               --title $"Restore from USB backup" \
491
+               --radiolist $"Choose an application to restore:" 30 70 27 \
492
+               1 $"Everything" on \
493
+               2 $"Return to the backup and restore menu" off \
494
+               3 $"Configuration files" off \
495
+               4 $"MariaDB settings" off \
496
+               5 $"Let's Encrypt account" off \
497
+               6 $"Mutt email client settings" off \
498
+               7 $"GPG keys" off \
499
+               8 $"Email processing rules" off \
500
+               9 $"Spam filtering rules" off \
501
+               10 $"Administrator's README file" off \
502
+               11 $"IPFS" off \
503
+               12 $"SSH keys" off \
504
+               13 $"User configuration files" off \
505
+               14 $"SSL/TLS certificates" off \
506
+               15 $"Personal settings" off \
507
+               16 $"Mailing List" off \
508
+               17 $"XMPP chat" off \
509
+               18 $"GNU Social" off \
510
+               19 $"Hubzilla" off \
511
+               20 $"Owncloud" off \
512
+               21 $"Gogs" off \
513
+               22 $"Wiki" off \
514
+               23 $"Blog" off \
515
+               24 $"CJDNS" off \
516
+               25 $"Email" off \
517
+               26 $"DLNA" off \
518
+               27 $"VoIP" off \
519
+               28 $"Tox" off 2> $data
520
+        sel=$?
521
+        case $sel in
522
+            1) break;;
523
+            255) break;;
524
+        esac
525
+        case $(cat $data) in
526
+            1) freedombone-restore-local $USB_DRIVE;;
527
+            2) return;;
528
+            3) freedombone-restore-local $USB_DRIVE configuration;;
529
+            4) freedombone-restore-local $USB_DRIVE mariadb;;
530
+            5) freedombone-restore-local $USB_DRIVE letsencrypt;;
531
+            6) freedombone-restore-local $USB_DRIVE mutt;;
532
+            7) freedombone-restore-local $USB_DRIVE gpg;;
533
+            8) freedombone-restore-local $USB_DRIVE procmail;;
534
+            9) freedombone-restore-local $USB_DRIVE spamassassin;;
535
+            10) freedombone-restore-local $USB_DRIVE readme;;
536
+            11) freedombone-restore-local $USB_DRIVE ipfs;;
537
+            12) freedombone-restore-local $USB_DRIVE ssh;;
538
+            13) freedombone-restore-local $USB_DRIVE userconfig;;
539
+            14) freedombone-restore-local $USB_DRIVE certs;;
540
+            15) freedombone-restore-local $USB_DRIVE personal;;
541
+            16) freedombone-restore-local $USB_DRIVE mailinglist;;
542
+            17) freedombone-restore-local $USB_DRIVE xmpp;;
543
+            18) freedombone-restore-local $USB_DRIVE gnusocial;;
544
+            19) freedombone-restore-local $USB_DRIVE hubzilla;;
545
+            20) freedombone-restore-local $USB_DRIVE owncloud;;
546
+            21) freedombone-restore-local $USB_DRIVE gogs;;
547
+            22) freedombone-restore-local $USB_DRIVE wiki;;
548
+            23) freedombone-restore-local $USB_DRIVE blog;;
549
+            24) freedombone-restore-local $USB_DRIVE cjdns;;
550
+            25) freedombone-restore-local $USB_DRIVE email;;
551
+            26) freedombone-restore-local $USB_DRIVE dlna;;
552
+            27) freedombone-restore-local $USB_DRIVE voip;;
553
+            28) freedombone-restore-local $USB_DRIVE tox;;
554
+        esac
555
+    done
556
+    any_key
557
+}
558
+
472 559
 function restore_data {
473 560
     dialog --title $"Restore data from USB" \
474 561
            --msgbox $"Plug in your backup USB drive" 6 40
475 562
     clear
476 563
     echo ' '
477 564
     echo $'Enter the passphrase for your LUKS encrypted backup drive:'
478
-    ${PROJECT_NAME}-restore-local
479
-    any_key
565
+    restore_from_usb
480 566
 }
481 567
 
482 568
 function restore_data_remote {