Browse Source

Tidying of backup and restore

Bob Mottram 8 years ago
parent
commit
20dffe1b61
2 changed files with 22 additions and 32 deletions
  1. 4
    8
      src/freedombone-mirrors
  2. 18
    24
      src/freedombone-utils-backup

+ 4
- 8
src/freedombone-mirrors View File

@@ -91,16 +91,12 @@ function create_mirrors_user {
91 91
         return
92 92
     fi
93 93
 
94
-    create_password='no'
95
-    if [ ! "$MY_MIRRORS_PASSWORD" ]; then
96
-        create_password='yes'
97
-    fi
98
-    if [ ${#MY_MIRRORS_PASSWORD} -lt ${MINIMUM_PASSWORD_LENGTH} ]; then
99
-        echo $'Password is too short. Creating new one.'
100
-        create_password='yes'
94
+    create_password=1
95
+    if [ ${#MY_MIRRORS_PASSWORD} -ge ${MINIMUM_PASSWORD_LENGTH} ]; then
96
+        create_password=
101 97
     fi
102 98
 
103
-    if [[ $create_password == 'yes' ]]; then
99
+    if [ $create_password ]; then
104 100
         MY_MIRRORS_PASSWORD="$(openssl rand -base64 20 | cut -c1-18)"
105 101
     fi
106 102
 

+ 18
- 24
src/freedombone-utils-backup View File

@@ -365,43 +365,37 @@ function backup_database_to_friend {
365 365
 
366 366
 function backup_apps {
367 367
     localremote=$1
368
-    FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
369 368
 
370 369
     BACKUP_APPS_COMPLETED=()
371 370
 
372
-    # for all the app scripts
373
-    for filename in $FILES
371
+    detect_installable_apps
372
+    get_apps_installed_names
373
+
374
+    for app_name in "${APPS_INSTALLED_NAMES[@]}"
374 375
     do
375
-        app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
376
-        if [[ $(item_in_array ${app_name} ${BACKUP_APPS_COMPLETED[@]}) != 0 ]]; then
377
-            if [[ "$(app_is_installed $a)" == "1" ]]; then
378
-                BACKUP_APPS_COMPLETED+=("${app_name}")
379
-                backup_${localremote}_${app_name}
380
-            fi
381
-        fi
376
+        echo $"Backup ${app_name}"
377
+        function_check backup_${localremote}_${app_name}
378
+        backup_${localremote}_${app_name}
379
+        BACKUP_APPS_COMPLETED+=("${app_name}")
380
+        echo $"Backup ${app_name} completed"
382 381
     done
383 382
 }
384 383
 
385 384
 function restore_apps {
386 385
     localremote=$1
387
-    FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
388 386
 
389 387
     RESTORE_APPS_COMPLETED=()
390 388
 
391
-    # for all the app scripts
392
-    for filename in $FILES
389
+    detect_installable_apps
390
+    get_apps_installed_names
391
+
392
+    for app_name in "${APPS_INSTALLED_NAMES[@]}"
393 393
     do
394
-        app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
395
-        if [[ $RESTORE_APP == 'all' || $RESTORE_APP == "${app_name}"  ]]; then
396
-            if [[ $(item_in_array ${app_name} ${RESTORE_APPS_COMPLETED[@]}) != 0 ]]; then
397
-                function_check app_is_installed
398
-                if [[ "$(app_is_installed $a)" == "1" ]]; then
399
-                    RESTORE_APPS_COMPLETED+=("${app_name}")
400
-                    function_check restore_${localremote}_${app_name}
401
-                    restore_${localremote}_${app_name}
402
-                fi
403
-            fi
404
-        fi
394
+        echo $"Restoring ${app_name}"
395
+        function_check restore_${localremote}_${app_name}
396
+        restore_${localremote}_${app_name}
397
+        RESTORE_APPS_COMPLETED+=("${app_name}")
398
+        echo $"Restored ${app_name}"
405 399
     done
406 400
 }
407 401