From 7ab85b55d2785d7d58fe2ac40998da5c857b9262 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 20 Jan 2018 10:21:38 +0000 Subject: [PATCH] Sometimes there is no shared data to restore --- src/freedombone-app-syncthing | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/freedombone-app-syncthing b/src/freedombone-app-syncthing index 9fe808a5..f1947ce6 100755 --- a/src/freedombone-app-syncthing +++ b/src/freedombone-app-syncthing @@ -13,7 +13,7 @@ # License # ======= # -# Copyright (C) 2014-2017 Bob Mottram +# Copyright (C) 2014-2018 Bob Mottram # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -318,14 +318,6 @@ function restore_local_syncthing { mkdir -p $SYNCTHING_SHARED_DATA fi cp -r ${temp_restore_dir}shared/* $SYNCTHING_SHARED_DATA/ - - if [ ! "$?" = "0" ]; then - set_user_permissions - backup_unmount_drive - systemctl start syncthing - systemctl start cron - exit 37904 - fi rm -rf ${temp_restore_dir}shared fi @@ -341,6 +333,9 @@ function restore_local_syncthing { if [ -d ${temp_restore_dir}/home/$USERNAME/Sync ]; then cp -r ${temp_restore_dir}/home/$USERNAME/Sync /home/$USERNAME/ else + if [ ! -d /home/$USERNAME/Sync ]; then + mkdir /home/$USERNAME/Sync + fi cp -r ${temp_restore_dir}/* /home/$USERNAME/Sync/ fi if [ ! "$?" = "0" ]; then @@ -425,7 +420,7 @@ function restore_remote_syncthing { if [ ! -d $SYNCTHING_CONFIG_PATH ]; then mkdir -p $SYNCTHING_CONFIG_PATH fi - cp -r ${temp_restore_dir}config/* $SYNCTHING_CONFIG_PATH/ + cp -r ${temp_restore_dir}/* $SYNCTHING_CONFIG_PATH/ if [ ! "$?" = "0" ]; then systemctl start syncthing systemctl start cron @@ -439,17 +434,11 @@ function restore_remote_syncthing { temp_restore_dir=/root/tempsyncthingshared function_check restore_directory_from_friend restore_directory_from_friend $temp_restore_dir syncthingshared - #cp -r $temp_restore_dir/* / if [ ! -d $SYNCTHING_SHARED_DATA ]; then mkdir -p $SYNCTHING_SHARED_DATA fi - cp -r ${temp_restore_dir}shared/* $SYNCTHING_SHARED_DATA/ - if [ ! "$?" = "0" ]; then - systemctl start syncthing - systemctl start cron - exit 37904 - fi - rm -rf $temp_restore_dir + cp -r ${temp_restore_dir}/* $SYNCTHING_SHARED_DATA/ + rm -rf ${temp_restore_dir} fi if [ -d $SERVER_DIRECTORY/backup/syncthing ]; then @@ -466,6 +455,9 @@ function restore_remote_syncthing { if [ -d $temp_restore_dir/home/$USERNAME/Sync ]; then cp -r $temp_restore_dir/home/$USERNAME/Sync /home/$USERNAME/ else + if [ ! -d /home/$USERNAME/Sync ]; then + mkdir /home/$USERNAME/Sync + fi cp -r $temp_restore_dir/* /home/$USERNAME/Sync/ fi if [ ! "$?" = "0" ]; then