瀏覽代碼

Configure remote backups via the control panel

Bob Mottram 9 年之前
父節點
當前提交
6823dd3865
共有 1 個檔案被更改,包括 33 行新增11 行删除
  1. 33
    11
      src/freedombone-controlpanel

+ 33
- 11
src/freedombone-controlpanel 查看文件

127
     if [ ! $SELECTED_USERNAME ]; then
127
     if [ ! $SELECTED_USERNAME ]; then
128
         return
128
         return
129
     fi
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
         dialog --title "Administrator user" \
131
         dialog --title "Administrator user" \
132
                --msgbox "You can't delete the administrator user" 6 40
132
                --msgbox "You can't delete the administrator user" 6 40
133
         return
133
         return
137
     any_key
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
 function change_password {
160
 function change_password {
141
     select_user
161
     select_user
142
     if [ ! $SELECTED_USERNAME ]; then
162
     if [ ! $SELECTED_USERNAME ]; then
155
         return
175
         return
156
     fi
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
         dialog --title "Change ssh public key" \
179
         dialog --title "Change ssh public key" \
160
                --backtitle "Freedombone Control Panel" \
180
                --backtitle "Freedombone Control Panel" \
161
                --defaultno \
181
                --defaultno \
504
         trap "rm -f $data" 0 1 2 5 15
524
         trap "rm -f $data" 0 1 2 5 15
505
         dialog --backtitle "Freedombone Control Panel" \
525
         dialog --backtitle "Freedombone Control Panel" \
506
                --title "Backup and Restore" \
526
                --title "Backup and Restore" \
507
-               --radiolist "Choose an operation:" 14 70 7 \
527
+               --radiolist "Choose an operation:" 15 70 8 \
508
                1 "Backup data to USB drive" off \
528
                1 "Backup data to USB drive" off \
509
                2 "Restore GPG key from USB keydrive" off \
529
                2 "Restore GPG key from USB keydrive" off \
510
                3 "Restore data from USB drive" off \
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
         sel=$?
536
         sel=$?
516
         case $sel in
537
         case $sel in
517
             1) break;;
538
             1) break;;
521
             1) backup_data;;
542
             1) backup_data;;
522
             2) restore_gpg_key;;
543
             2) restore_gpg_key;;
523
             3) restore_data;;
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
         esac
550
         esac
529
     done
551
     done
530
 }
552
 }