From 6823dd386523080e4f05856f3d3b980a27c75f58 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 3 Nov 2015 15:30:10 +0000 Subject: [PATCH] Configure remote backups via the control panel --- src/freedombone-controlpanel | 44 +++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/src/freedombone-controlpanel b/src/freedombone-controlpanel index 548183c0..62b39be1 100755 --- a/src/freedombone-controlpanel +++ b/src/freedombone-controlpanel @@ -127,7 +127,7 @@ function delete_user { if [ ! $SELECTED_USERNAME ]; then return fi - if grep -Fxq "Admin user: $SELECTED_USERNAME" $COMPLETION_FILE; then + if grep -Fxq "Admin user:$SELECTED_USERNAME" $COMPLETION_FILE; then dialog --title "Administrator user" \ --msgbox "You can't delete the administrator user" 6 40 return @@ -137,6 +137,26 @@ function delete_user { any_key } +function configure_remote_backups { + if ! grep -Fxq "Admin user:$SELECTED_USERNAME" $COMPLETION_FILE; then + dialog --title "Administrator user" \ + --msgbox "No Administrator user found. Check $COMPLETION_FILE" 6 40 + return + fi + ADMIN_USER=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}') + if [ ${#ADMIN} -lt 2 ]; then + dialog --title "Administrator user" \ + --msgbox "Username not found" 6 40 + return + fi + if [ ! -d /home/$ADMIN_USER ]; then + dialog --title "Administrator user" \ + --msgbox "Home directory not found" 6 40 + return + fi + freedombone-remote -u $ADMIN_USER +} + function change_password { select_user if [ ! $SELECTED_USERNAME ]; then @@ -155,7 +175,7 @@ function change_ssh_public_key { return fi - if grep -Fxq "Admin user: $SELECTED_USERNAME" $COMPLETION_FILE; then + if grep -Fxq "Admin user:$SELECTED_USERNAME" $COMPLETION_FILE; then dialog --title "Change ssh public key" \ --backtitle "Freedombone Control Panel" \ --defaultno \ @@ -504,14 +524,15 @@ function menu_backup_restore { trap "rm -f $data" 0 1 2 5 15 dialog --backtitle "Freedombone Control Panel" \ --title "Backup and Restore" \ - --radiolist "Choose an operation:" 14 70 7 \ + --radiolist "Choose an operation:" 15 70 8 \ 1 "Backup data to USB drive" off \ 2 "Restore GPG key from USB keydrive" off \ 3 "Restore data from USB drive" off \ - 4 "Restore from remote backup" off \ - 5 "Backup GPG key to USB (master keydrive)" off \ - 6 "Backup GPG key to USB (fragment keydrive)" off \ - 7 "Back to main menu" on 2> $data + 4 "Configure remote backups" off \ + 5 "Restore from remote backup" off \ + 6 "Backup GPG key to USB (master keydrive)" off \ + 7 "Backup GPG key to USB (fragment keydrive)" off \ + 8 "Back to main menu" on 2> $data sel=$? case $sel in 1) break;; @@ -521,10 +542,11 @@ function menu_backup_restore { 1) backup_data;; 2) restore_gpg_key;; 3) restore_data;; - 4) restore_data_remote;; - 5) create_keydrive_master;; - 6) create_keydrive_fragment;; - 7) break;; + 4) configure_remote_backups;; + 5) restore_data_remote;; + 6) create_keydrive_master;; + 7) create_keydrive_fragment;; + 8) break;; esac done }