Kaynağa Gözat

Configure remote backups via the control panel

Bob Mottram 9 yıl önce
ebeveyn
işleme
6823dd3865
1 değiştirilmiş dosya ile 33 ekleme ve 11 silme
  1. 33
    11
      src/freedombone-controlpanel

+ 33
- 11
src/freedombone-controlpanel Dosyayı Görüntüle

@@ -127,7 +127,7 @@ function delete_user {
127 127
     if [ ! $SELECTED_USERNAME ]; then
128 128
         return
129 129
     fi
130
-    if grep -Fxq "Admin user: $SELECTED_USERNAME" $COMPLETION_FILE; then
130
+    if grep -Fxq "Admin user:$SELECTED_USERNAME" $COMPLETION_FILE; then
131 131
         dialog --title "Administrator user" \
132 132
                --msgbox "You can't delete the administrator user" 6 40
133 133
         return
@@ -137,6 +137,26 @@ function delete_user {
137 137
     any_key
138 138
 }
139 139
 
140
+function configure_remote_backups {
141
+    if ! grep -Fxq "Admin user:$SELECTED_USERNAME" $COMPLETION_FILE; then
142
+        dialog --title "Administrator user" \
143
+               --msgbox "No Administrator user found. Check $COMPLETION_FILE" 6 40
144
+        return
145
+    fi
146
+    ADMIN_USER=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
147
+    if [ ${#ADMIN} -lt 2 ]; then
148
+        dialog --title "Administrator user" \
149
+               --msgbox "Username not found" 6 40
150
+        return      
151
+    fi
152
+    if [ ! -d /home/$ADMIN_USER ]; then
153
+        dialog --title "Administrator user" \
154
+               --msgbox "Home directory not found" 6 40
155
+        return
156
+    fi
157
+    freedombone-remote -u $ADMIN_USER
158
+}
159
+
140 160
 function change_password {
141 161
     select_user
142 162
     if [ ! $SELECTED_USERNAME ]; then
@@ -155,7 +175,7 @@ function change_ssh_public_key {
155 175
         return
156 176
     fi
157 177
 
158
-    if grep -Fxq "Admin user: $SELECTED_USERNAME" $COMPLETION_FILE; then
178
+    if grep -Fxq "Admin user:$SELECTED_USERNAME" $COMPLETION_FILE; then
159 179
         dialog --title "Change ssh public key" \
160 180
                --backtitle "Freedombone Control Panel" \
161 181
                --defaultno \
@@ -504,14 +524,15 @@ function menu_backup_restore {
504 524
         trap "rm -f $data" 0 1 2 5 15
505 525
         dialog --backtitle "Freedombone Control Panel" \
506 526
                --title "Backup and Restore" \
507
-               --radiolist "Choose an operation:" 14 70 7 \
527
+               --radiolist "Choose an operation:" 15 70 8 \
508 528
                1 "Backup data to USB drive" off \
509 529
                2 "Restore GPG key from USB keydrive" off \
510 530
                3 "Restore data from USB drive" off \
511
-               4 "Restore from remote backup" off \
512
-               5 "Backup GPG key to USB (master keydrive)" off \
513
-               6 "Backup GPG key to USB (fragment keydrive)" off \
514
-               7 "Back to main menu" on 2> $data
531
+               4 "Configure remote backups" off \
532
+               5 "Restore from remote backup" off \
533
+               6 "Backup GPG key to USB (master keydrive)" off \
534
+               7 "Backup GPG key to USB (fragment keydrive)" off \
535
+               8 "Back to main menu" on 2> $data
515 536
         sel=$?
516 537
         case $sel in
517 538
             1) break;;
@@ -521,10 +542,11 @@ function menu_backup_restore {
521 542
             1) backup_data;;
522 543
             2) restore_gpg_key;;
523 544
             3) restore_data;;
524
-            4) restore_data_remote;;
525
-            5) create_keydrive_master;;
526
-            6) create_keydrive_fragment;;
527
-            7) break;;
545
+            4) configure_remote_backups;;
546
+            5) restore_data_remote;;
547
+            6) create_keydrive_master;;
548
+            7) create_keydrive_fragment;;
549
+            8) break;;
528 550
         esac
529 551
     done
530 552
 }