Bladeren bron

Sometimes there is no shared data to restore

Bob Mottram 7 jaren geleden
bovenliggende
commit
7ab85b55d2
1 gewijzigde bestanden met toevoegingen van 10 en 18 verwijderingen
  1. 10
    18
      src/freedombone-app-syncthing

+ 10
- 18
src/freedombone-app-syncthing Bestand weergeven

13
 # License
13
 # License
14
 # =======
14
 # =======
15
 #
15
 #
16
-# Copyright (C) 2014-2017 Bob Mottram <bob@freedombone.net>
16
+# Copyright (C) 2014-2018 Bob Mottram <bob@freedombone.net>
17
 #
17
 #
18
 # This program is free software: you can redistribute it and/or modify
18
 # This program is free software: you can redistribute it and/or modify
19
 # it under the terms of the GNU Affero General Public License as published by
19
 # it under the terms of the GNU Affero General Public License as published by
318
             mkdir -p $SYNCTHING_SHARED_DATA
318
             mkdir -p $SYNCTHING_SHARED_DATA
319
         fi
319
         fi
320
         cp -r ${temp_restore_dir}shared/* $SYNCTHING_SHARED_DATA/
320
         cp -r ${temp_restore_dir}shared/* $SYNCTHING_SHARED_DATA/
321
-
322
-        if [ ! "$?" = "0" ]; then
323
-            set_user_permissions
324
-            backup_unmount_drive
325
-            systemctl start syncthing
326
-            systemctl start cron
327
-            exit 37904
328
-        fi
329
         rm -rf ${temp_restore_dir}shared
321
         rm -rf ${temp_restore_dir}shared
330
     fi
322
     fi
331
 
323
 
341
                 if [ -d ${temp_restore_dir}/home/$USERNAME/Sync ]; then
333
                 if [ -d ${temp_restore_dir}/home/$USERNAME/Sync ]; then
342
                     cp -r ${temp_restore_dir}/home/$USERNAME/Sync /home/$USERNAME/
334
                     cp -r ${temp_restore_dir}/home/$USERNAME/Sync /home/$USERNAME/
343
                 else
335
                 else
336
+                    if [ ! -d /home/$USERNAME/Sync ]; then
337
+                        mkdir /home/$USERNAME/Sync
338
+                    fi
344
                     cp -r ${temp_restore_dir}/* /home/$USERNAME/Sync/
339
                     cp -r ${temp_restore_dir}/* /home/$USERNAME/Sync/
345
                 fi
340
                 fi
346
                 if [ ! "$?" = "0" ]; then
341
                 if [ ! "$?" = "0" ]; then
425
         if [ ! -d $SYNCTHING_CONFIG_PATH ]; then
420
         if [ ! -d $SYNCTHING_CONFIG_PATH ]; then
426
             mkdir -p $SYNCTHING_CONFIG_PATH
421
             mkdir -p $SYNCTHING_CONFIG_PATH
427
         fi
422
         fi
428
-        cp -r ${temp_restore_dir}config/* $SYNCTHING_CONFIG_PATH/
423
+        cp -r ${temp_restore_dir}/* $SYNCTHING_CONFIG_PATH/
429
         if [ ! "$?" = "0" ]; then
424
         if [ ! "$?" = "0" ]; then
430
             systemctl start syncthing
425
             systemctl start syncthing
431
             systemctl start cron
426
             systemctl start cron
439
         temp_restore_dir=/root/tempsyncthingshared
434
         temp_restore_dir=/root/tempsyncthingshared
440
         function_check restore_directory_from_friend
435
         function_check restore_directory_from_friend
441
         restore_directory_from_friend $temp_restore_dir syncthingshared
436
         restore_directory_from_friend $temp_restore_dir syncthingshared
442
-        #cp -r $temp_restore_dir/* /
443
         if [ ! -d $SYNCTHING_SHARED_DATA ]; then
437
         if [ ! -d $SYNCTHING_SHARED_DATA ]; then
444
             mkdir -p $SYNCTHING_SHARED_DATA
438
             mkdir -p $SYNCTHING_SHARED_DATA
445
         fi
439
         fi
446
-        cp -r ${temp_restore_dir}shared/* $SYNCTHING_SHARED_DATA/
447
-        if [ ! "$?" = "0" ]; then
448
-            systemctl start syncthing
449
-            systemctl start cron
450
-            exit 37904
451
-        fi
452
-        rm -rf $temp_restore_dir
440
+        cp -r ${temp_restore_dir}/* $SYNCTHING_SHARED_DATA/
441
+        rm -rf ${temp_restore_dir}
453
     fi
442
     fi
454
 
443
 
455
     if [ -d $SERVER_DIRECTORY/backup/syncthing ]; then
444
     if [ -d $SERVER_DIRECTORY/backup/syncthing ]; then
466
                 if [ -d $temp_restore_dir/home/$USERNAME/Sync ]; then
455
                 if [ -d $temp_restore_dir/home/$USERNAME/Sync ]; then
467
                     cp -r $temp_restore_dir/home/$USERNAME/Sync /home/$USERNAME/
456
                     cp -r $temp_restore_dir/home/$USERNAME/Sync /home/$USERNAME/
468
                 else
457
                 else
458
+                    if [ ! -d /home/$USERNAME/Sync ]; then
459
+                        mkdir /home/$USERNAME/Sync
460
+                    fi
469
                     cp -r $temp_restore_dir/* /home/$USERNAME/Sync/
461
                     cp -r $temp_restore_dir/* /home/$USERNAME/Sync/
470
                 fi
462
                 fi
471
                 if [ ! "$?" = "0" ]; then
463
                 if [ ! "$?" = "0" ]; then