Pārlūkot izejas kodu

Move syncthing local restore to app script

Bob Mottram 8 gadus atpakaļ
vecāks
revīzija
2b9df463b4
2 mainītis faili ar 79 papildinājumiem un 80 dzēšanām
  1. 79
    0
      src/freedombone-app-syncthing
  2. 0
    80
      src/freedombone-restore-local

+ 79
- 0
src/freedombone-app-syncthing Parādīt failu

@@ -55,10 +55,89 @@ function backup_local_syncthing {
55 55
 	fi
56 56
 }
57 57
 
58
+function restore_local_syncthing {
59
+	if [ -f /etc/systemd/system/syncthing.service ]; then
60
+		systemctl stop syncthing
61
+		systemctl stop cron
62
+	fi
63
+
64
+	temp_restore_dir=/root/tempsyncthing
65
+	if [ -d $USB_MOUNT/backup/syncthingconfig ]; then
66
+		echo $"Restoring syncthing configuration"
67
+		function_check restore_directory_from_usb
68
+		restore_directory_from_usb ${temp_restore_dir}config syncthingconfig
69
+		cp -r ${temp_restore_dir}config/* /
70
+		if [ ! "$?" = "0" ]; then
71
+			set_user_permissions
72
+			backup_unmount_drive
73
+			systemctl start syncthing
74
+			systemctl start cron
75
+			exit 6833
76
+		fi
77
+		rm -rf ${temp_restore_dir}config
78
+	fi
79
+
80
+	if [ -d $USB_MOUNT/backup/syncthingshared ]; then
81
+		echo $"Restoring syncthing shared files"
82
+		restore_directory_from_usb ${temp_restore_dir}shared syncthingshared
83
+		cp -r ${temp_restore_dir}shared/* /
84
+		if [ ! "$?" = "0" ]; then
85
+			set_user_permissions
86
+			backup_unmount_drive
87
+			systemctl start syncthing
88
+			systemctl start cron
89
+			exit 37904
90
+		fi
91
+		rm -rf ${temp_restore_dir}shared
92
+	fi
93
+
94
+	if [ -d $USB_MOUNT/backup/syncthing ]; then
95
+		for d in $USB_MOUNT/backup/syncthing/*/ ; do
96
+			USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
97
+			if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
98
+				if [ ! -d /home/$USERNAME ]; then
99
+					${PROJECT_NAME}-adduser $USERNAME
100
+				fi
101
+				echo $"Restoring syncthing files for $USERNAME"
102
+				restore_directory_from_usb ${temp_restore_dir} syncthing/$USERNAME
103
+				cp -r ${temp_restore_dir}/home/$USERNAME/Sync /home/$USERNAME/
104
+				if [ ! "$?" = "0" ]; then
105
+					rm -rf ${temp_restore_dir}
106
+					set_user_permissions
107
+					backup_unmount_drive
108
+					systemctl start syncthing
109
+					systemctl start cron
110
+					exit 68438
111
+				fi
112
+				rm -rf ${temp_restore_dir}
113
+
114
+				# restore device IDs from config settings
115
+				if [ -f /home/$USERNAME/.config/syncthing/.syncthing-server-id ]; then
116
+					cp /home/$USERNAME/.config/syncthing/.syncthing-server-id /home/$USERNAME/.syncthing-server-id
117
+					chown $USERNAME:$USERNAME /home/$USERNAME/.syncthing-server-id
118
+				fi
119
+				if [ -f /home/$USERNAME/.config/syncthing/.syncthingids ]; then
120
+					cp /home/$USERNAME/.config/syncthing/.syncthingids /home/$USERNAME/.syncthingids
121
+					chown $USERNAME:$USERNAME /home/$USERNAME/.syncthingids
122
+				fi
123
+			fi
124
+		done
125
+	fi
126
+
127
+	if [ -f /etc/systemd/system/syncthing.service ]; then
128
+		systemctl start syncthing
129
+		systemctl start cron
130
+	fi
131
+}
132
+
58 133
 function backup_remote_syncthing {
59 134
 	echo -n ''
60 135
 }
61 136
 
137
+function restore_remote_syncthing {
138
+	echo -n ''
139
+}
140
+
62 141
 function remove_syncthing {
63 142
 	if ! grep -Fxq "install_syncthing" $COMPLETION_FILE; then
64 143
 		return

+ 0
- 80
src/freedombone-restore-local Parādīt failu

@@ -878,85 +878,6 @@ function restore_hubzilla {
878 878
     fi
879 879
 }
880 880
 
881
-function restore_syncthing {
882
-    if [[ $RESTORE_APP != 'all' ]]; then
883
-        if [[ $RESTORE_APP != 'syncthing' ]]; then
884
-            return
885
-        fi
886
-    fi
887
-
888
-    if [ -f /etc/systemd/system/syncthing.service ]; then
889
-        systemctl stop syncthing
890
-        systemctl stop cron
891
-    fi
892
-
893
-    if [ -d $USB_MOUNT/backup/syncthingconfig ]; then
894
-        echo $"Restoring syncthing configuration"
895
-        restore_directory_from_usb /root/tempsyncthingconfig syncthingconfig
896
-        cp -r /root/tempsyncthingconfig/* /
897
-        if [ ! "$?" = "0" ]; then
898
-            set_user_permissions
899
-            backup_unmount_drive
900
-            systemctl start syncthing
901
-            systemctl start cron
902
-            exit 6833
903
-        fi
904
-        rm -rf /root/tempsyncthingconfig
905
-    fi
906
-
907
-    if [ -d $USB_MOUNT/backup/syncthingshared ]; then
908
-        echo $"Restoring syncthing shared files"
909
-        restore_directory_from_usb /root/tempsyncthingshared syncthingshared
910
-        cp -r /root/tempsyncthingshared/* /
911
-        if [ ! "$?" = "0" ]; then
912
-            set_user_permissions
913
-            backup_unmount_drive
914
-            systemctl start syncthing
915
-            systemctl start cron
916
-            exit 37904
917
-        fi
918
-        rm -rf /root/tempsyncthingshared
919
-    fi
920
-
921
-    if [ -d $USB_MOUNT/backup/syncthing ]; then
922
-        for d in $USB_MOUNT/backup/syncthing/*/ ; do
923
-            USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
924
-            if [[ $USERNAME != "git" && $USERNAME != "mirrors" && $USERNAME != "sync" ]]; then
925
-                if [ ! -d /home/$USERNAME ]; then
926
-                    ${PROJECT_NAME}-adduser $USERNAME
927
-                fi
928
-                echo $"Restoring syncthing files for $USERNAME"
929
-                restore_directory_from_usb /root/tempsyncthing syncthing/$USERNAME
930
-                cp -r /root/tempsyncthing/home/$USERNAME/Sync /home/$USERNAME/
931
-                if [ ! "$?" = "0" ]; then
932
-                    rm -rf /root/tempsyncthing
933
-                    set_user_permissions
934
-                    backup_unmount_drive
935
-                    systemctl start syncthing
936
-                    systemctl start cron
937
-                    exit 68438
938
-                fi
939
-                rm -rf /root/tempsyncthing
940
-
941
-                # restore device IDs from config settings
942
-                if [ -f /home/$USERNAME/.config/syncthing/.syncthing-server-id ]; then
943
-                    cp /home/$USERNAME/.config/syncthing/.syncthing-server-id /home/$USERNAME/.syncthing-server-id
944
-                    chown $USERNAME:$USERNAME /home/$USERNAME/.syncthing-server-id
945
-                fi
946
-                if [ -f /home/$USERNAME/.config/syncthing/.syncthingids ]; then
947
-                    cp /home/$USERNAME/.config/syncthing/.syncthingids /home/$USERNAME/.syncthingids
948
-                    chown $USERNAME:$USERNAME /home/$USERNAME/.syncthingids
949
-                fi
950
-            fi
951
-        done
952
-    fi
953
-
954
-    if [ -f /etc/systemd/system/syncthing.service ]; then
955
-        systemctl start syncthing
956
-        systemctl start cron
957
-    fi
958
-}
959
-
960 881
 function restore_email {
961 882
     if [[ $RESTORE_APP != 'all' ]]; then
962 883
         if [[ $RESTORE_APP != 'email' ]]; then
@@ -1049,7 +970,6 @@ restore_xmpp
1049 970
 restore_gnusocial
1050 971
 restore_hubzilla
1051 972
 restore_rss
1052
-restore_syncthing
1053 973
 
1054 974
 restore_email
1055 975
 restore_apps