From 20dffe1b610c997cebbcbc46293be349360d96b9 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 2 Oct 2016 15:23:04 +0100 Subject: [PATCH] Tidying of backup and restore --- src/freedombone-mirrors | 12 ++++------- src/freedombone-utils-backup | 42 ++++++++++++++++-------------------- 2 files changed, 22 insertions(+), 32 deletions(-) diff --git a/src/freedombone-mirrors b/src/freedombone-mirrors index 68844278..a0a477ea 100755 --- a/src/freedombone-mirrors +++ b/src/freedombone-mirrors @@ -91,16 +91,12 @@ function create_mirrors_user { return fi - create_password='no' - if [ ! "$MY_MIRRORS_PASSWORD" ]; then - create_password='yes' - fi - if [ ${#MY_MIRRORS_PASSWORD} -lt ${MINIMUM_PASSWORD_LENGTH} ]; then - echo $'Password is too short. Creating new one.' - create_password='yes' + create_password=1 + if [ ${#MY_MIRRORS_PASSWORD} -ge ${MINIMUM_PASSWORD_LENGTH} ]; then + create_password= fi - if [[ $create_password == 'yes' ]]; then + if [ $create_password ]; then MY_MIRRORS_PASSWORD="$(openssl rand -base64 20 | cut -c1-18)" fi diff --git a/src/freedombone-utils-backup b/src/freedombone-utils-backup index 3b934e9e..ea4d074b 100755 --- a/src/freedombone-utils-backup +++ b/src/freedombone-utils-backup @@ -365,43 +365,37 @@ function backup_database_to_friend { function backup_apps { localremote=$1 - FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-* BACKUP_APPS_COMPLETED=() - # for all the app scripts - for filename in $FILES + detect_installable_apps + get_apps_installed_names + + for app_name in "${APPS_INSTALLED_NAMES[@]}" do - app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}') - if [[ $(item_in_array ${app_name} ${BACKUP_APPS_COMPLETED[@]}) != 0 ]]; then - if [[ "$(app_is_installed $a)" == "1" ]]; then - BACKUP_APPS_COMPLETED+=("${app_name}") - backup_${localremote}_${app_name} - fi - fi + echo $"Backup ${app_name}" + function_check backup_${localremote}_${app_name} + backup_${localremote}_${app_name} + BACKUP_APPS_COMPLETED+=("${app_name}") + echo $"Backup ${app_name} completed" done } function restore_apps { localremote=$1 - FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-* RESTORE_APPS_COMPLETED=() - # for all the app scripts - for filename in $FILES + detect_installable_apps + get_apps_installed_names + + for app_name in "${APPS_INSTALLED_NAMES[@]}" do - app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}') - if [[ $RESTORE_APP == 'all' || $RESTORE_APP == "${app_name}" ]]; then - if [[ $(item_in_array ${app_name} ${RESTORE_APPS_COMPLETED[@]}) != 0 ]]; then - function_check app_is_installed - if [[ "$(app_is_installed $a)" == "1" ]]; then - RESTORE_APPS_COMPLETED+=("${app_name}") - function_check restore_${localremote}_${app_name} - restore_${localremote}_${app_name} - fi - fi - fi + echo $"Restoring ${app_name}" + function_check restore_${localremote}_${app_name} + restore_${localremote}_${app_name} + RESTORE_APPS_COMPLETED+=("${app_name}") + echo $"Restored ${app_name}" done }