From 7f970fe02c14f2354bc015cf1e7774adb7aa166a Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 20 Oct 2016 17:24:23 +0100 Subject: [PATCH] Check files --- src/freedombone-restore-local | 29 +++++++++++++++++------------ src/freedombone-restore-remote | 25 +++++++++++++++---------- 2 files changed, 32 insertions(+), 22 deletions(-) diff --git a/src/freedombone-restore-local b/src/freedombone-restore-local index c2ca8cc2..874a067f 100755 --- a/src/freedombone-restore-local +++ b/src/freedombone-restore-local @@ -112,24 +112,29 @@ function restore_configuration { temp_restore_dir=/root/tempconfig restore_directory_from_usb $temp_restore_dir config - cp -f $temp_restore_dir/root/${PROJECT_NAME}.cfg $CONFIGURATION_FILE - if [ ! "$?" = "0" ]; then - set_user_permissions - backup_unmount_drive - rm -rf $temp_restore_dir - exit 5294 + if [ -f $temp_restore_dir/root/${PROJECT_NAME}.cfg ]; then + cp -f $temp_restore_dir/root/${PROJECT_NAME}.cfg $CONFIGURATION_FILE + if [ ! "$?" = "0" ]; then + set_user_permissions + backup_unmount_drive + rm -rf $temp_restore_dir + exit 5294 + fi fi + if [ -f $CONFIGURATION_FILE ]; then # install according to the config file freedombone -c $CONFIGURATION_FILE fi - cp -f $temp_restore_dir/root/${PROJECT_NAME}-completed.txt $COMPLETION_FILE - if [ ! "$?" = "0" ]; then - set_user_permissions - backup_unmount_drive - rm -rf $temp_restore_dir - exit 6382 + if [ -f $temp_restore_dir/root/${PROJECT_NAME}-completed.txt ]; then + cp -f $temp_restore_dir/root/${PROJECT_NAME}-completed.txt $COMPLETION_FILE + if [ ! "$?" = "0" ]; then + set_user_permissions + backup_unmount_drive + rm -rf $temp_restore_dir + exit 6382 + fi fi if [ -f ${temp_restore_dir}${BACKUP_EXTRA_DIRECTORIES} ]; then diff --git a/src/freedombone-restore-remote b/src/freedombone-restore-remote index 7177dae5..ddca829d 100755 --- a/src/freedombone-restore-remote +++ b/src/freedombone-restore-remote @@ -119,22 +119,27 @@ function restore_configuration { temp_restore_dir=/root/tempconfig restore_directory_from_friend $temp_restore_dir config - cp -f $temp_restore_dir/root/${PROJECT_NAME}.cfg $CONFIGURATION_FILE - if [ ! "$?" = "0" ]; then - unmount_drive - rm -rf $temp_restore_dir - exit 5372 + if [ -f $temp_restore_dir/root/${PROJECT_NAME}.cfg ]; then + cp -f $temp_restore_dir/root/${PROJECT_NAME}.cfg $CONFIGURATION_FILE + if [ ! "$?" = "0" ]; then + unmount_drive + rm -rf $temp_restore_dir + exit 5372 + fi fi + if [ -f $CONFIGURATION_FILE ]; then # install according to the config file freedombone -c $CONFIGURATION_FILE fi - cp -f $temp_restore_dir/root/${PROJECT_NAME}-completed.txt $COMPLETION_FILE - if [ ! "$?" = "0" ]; then - unmount_drive - rm -rf $temp_restore_dir - exit 7252 + if [ -f $temp_restore_dir/root/${PROJECT_NAME}-completed.txt ]; then + cp -f $temp_restore_dir/root/${PROJECT_NAME}-completed.txt $COMPLETION_FILE + if [ ! "$?" = "0" ]; then + unmount_drive + rm -rf $temp_restore_dir + exit 7252 + fi fi if [ -f ${temp_restore_dir}${BACKUP_EXTRA_DIRECTORIES} ]; then