浏览代码

Merge branch 'stretch' of https://github.com/bashrc/freedombone

Bob Mottram 8 年前
父节点
当前提交
e9dc1550df

+ 2
- 0
doc/EN/app_matrix.org 查看文件

22
 
22
 
23
 Matrix is a federated communications system, typically for multi-user chat, with end-to-end content security features. You can consider it to be like a modernized version of IRC chat where the crypto and access controls have been built in by default. At present Matrix is really only a creature of the clearnet and so there isn't any way to protect the metadata. Despite the talk of security the lack of metadata defenses make this really only suitable for public communications, similar to microblogging or public IRC channels.
23
 Matrix is a federated communications system, typically for multi-user chat, with end-to-end content security features. You can consider it to be like a modernized version of IRC chat where the crypto and access controls have been built in by default. At present Matrix is really only a creature of the clearnet and so there isn't any way to protect the metadata. Despite the talk of security the lack of metadata defenses make this really only suitable for public communications, similar to microblogging or public IRC channels.
24
 
24
 
25
+Another consideration is that since matrix operates on the usual HTTPS port number (443) this may make it difficult for ISPs or governments to censor this type of communications via port blocking without significant blowback.
26
+
25
 * Installation
27
 * Installation
26
 Log into your system with:
28
 Log into your system with:
27
 
29
 

+ 27
- 2
src/freedombone-app-cryptpad 查看文件

122
         temp_restore_dir=/root/tempcryptpad
122
         temp_restore_dir=/root/tempcryptpad
123
         function_check restore_directory_from_usb
123
         function_check restore_directory_from_usb
124
         restore_directory_from_usb $temp_restore_dir cryptpad
124
         restore_directory_from_usb $temp_restore_dir cryptpad
125
-        cp -r $temp_restore_dir$CRYPTPAD_DIR/datastore/* $CRYPTPAD_DIR/datastore/
125
+        if [ ! -d $temp_restore_dir$CRYPTPAD_DIR/datastore ]; then
126
+            if [ -d $temp_restore_dir ]; then
127
+                cp -r $temp_restore_dir/* $CRYPTPAD_DIR/datastore/
128
+            else
129
+                systemctl start cryptpad
130
+                echo 'Failed to restore cryptpad'
131
+                rm -rf $temp_restore_dir
132
+                exit 8736529
133
+            fi
134
+        else
135
+            cp -r $temp_restore_dir$CRYPTPAD_DIR/datastore/* $CRYPTPAD_DIR/datastore/
136
+        fi
137
+        rm -rf $temp_restore_dir
126
         systemctl start cryptpad
138
         systemctl start cryptpad
127
     fi
139
     fi
128
 }
140
 }
157
         temp_restore_dir=/root/tempcryptpad
169
         temp_restore_dir=/root/tempcryptpad
158
         function_check restore_directory_from_usb
170
         function_check restore_directory_from_usb
159
         restore_directory_from_friend $temp_restore_dir cryptpad
171
         restore_directory_from_friend $temp_restore_dir cryptpad
160
-        cp -r $temp_restore_dir$CRYPTPAD_DIR/datastore/* $CRYPTPAD_DIR/datastore/
172
+
173
+        if [ ! -d $temp_restore_dir$CRYPTPAD_DIR/datastore ]; then
174
+            if [ -d $temp_restore_dir ]; then
175
+                cp -r $temp_restore_dir/* $CRYPTPAD_DIR/datastore/
176
+            else
177
+                systemctl start cryptpad
178
+                echo 'Failed to restore cryptpad'
179
+                rm -rf $temp_restore_dir
180
+                return
181
+            fi
182
+        else
183
+            cp -r $temp_restore_dir$CRYPTPAD_DIR/datastore/* $CRYPTPAD_DIR/datastore/
184
+        fi
185
+        rm -rf $temp_restore_dir
161
         systemctl start cryptpad
186
         systemctl start cryptpad
162
     fi
187
     fi
163
 }
188
 }

+ 10
- 2
src/freedombone-app-dlna 查看文件

113
             temp_restore_dir=/root/tempdlna
113
             temp_restore_dir=/root/tempdlna
114
             function_check restore_directory_from_usb
114
             function_check restore_directory_from_usb
115
             restore_directory_from_usb $temp_restore_dir dlna
115
             restore_directory_from_usb $temp_restore_dir dlna
116
-            cp -r $temp_restore_dir/var/cache/minidlna/* /var/cache/minidlna/
116
+            if [ -d $temp_restore_dir/var/cache/minidlna ]; then
117
+                cp -r $temp_restore_dir/var/cache/minidlna/* /var/cache/minidlna/
118
+            else
119
+                cp -r $temp_restore_dir/* /var/cache/minidlna/
120
+            fi
117
             if [ ! "$?" = "0" ]; then
121
             if [ ! "$?" = "0" ]; then
118
                 rm -rf $temp_restore_dir
122
                 rm -rf $temp_restore_dir
119
                 function_check set_user_permissions
123
                 function_check set_user_permissions
139
             temp_restore_dir=/root/tempdlna
143
             temp_restore_dir=/root/tempdlna
140
             function_check restore_directory_from_friend
144
             function_check restore_directory_from_friend
141
             restore_directory_from_friend $temp_restore_dir dlna
145
             restore_directory_from_friend $temp_restore_dir dlna
142
-            cp -r $temp_restore_dir/var/cache/minidlna/* /var/cache/minidlna/
146
+            if [ -d $temp_restore_dir/var/cache/minidlna ]; then
147
+                cp -r $temp_restore_dir/var/cache/minidlna/* /var/cache/minidlna/
148
+            else
149
+                cp -r $temp_restore_dir/* /var/cache/minidlna/
150
+            fi
143
             if [ ! "$?" = "0" ]; then
151
             if [ ! "$?" = "0" ]; then
144
                 exit 982
152
                 exit 982
145
             fi
153
             fi

+ 29
- 62
src/freedombone-app-dokuwiki 查看文件

13
 # License
13
 # License
14
 # =======
14
 # =======
15
 #
15
 #
16
-# Copyright (C) 2014-2016 Bob Mottram <bob@freedombone.net>
16
+# Copyright (C) 2014-2017 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
144
     fi
144
     fi
145
 }
145
 }
146
 
146
 
147
-function restore_local_dokuwiki_legacy {
148
-    if [ -d /var/lib/dokuwiki ]; then
149
-        echo $"Restoring Legacy Dokuwiki installation"
150
-        function_check get_completion_param
151
-        DOKUWIKI_DOMAIN_NAME=$(get_completion_param "dokuwiki domain")
152
-
153
-        temp_restore_dir=/root/tempdokuwiki
154
-        function_check restore_directory_from_usb
155
-        if [ -d ${USB_MOUNT}/backup/dokuwiki ]; then
156
-            restore_directory_from_usb ${temp_restore_dir} dokuwiki
157
-        else
158
-            restore_directory_from_usb ${temp_restore_dir} wiki
159
-        fi
160
-
161
-        # restore the data
162
-        cp -r ${temp_restore_dir}/var/lib/dokuwiki/data/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data
163
-        if [ ! "$?" = "0" ]; then
164
-            function_check restore_directory_from_usb
165
-            set_user_permissions
166
-            function_check backup_unmount_drive
167
-            backup_unmount_drive
168
-            rm -rf ${temp_restore_dir}
169
-            exit 73562
170
-        fi
171
-
172
-        # restore the users
173
-        cp -r ${temp_restore_dir}/var/lib/dokuwiki/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl
174
-        cp -r ${temp_restore_dir}/var/lib/dokuwiki/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/conf
175
-        if [ ! "$?" = "0" ]; then
176
-            function_check restore_directory_from_usb
177
-            set_user_permissions
178
-            function_check backup_unmount_drive
179
-            backup_unmount_drive
180
-            rm -rf ${temp_restore_dir}
181
-            exit 23985
182
-        fi
183
-        rm -rf ${temp_restore_dir}
184
-
185
-        chmod -R 755 /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data
186
-        chmod -R 755 /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib
187
-        chmod 640 /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/users.auth.php
188
-        chmod 640 /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/conf/users.auth.php
189
-        chown -R www-data:www-data /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs
190
-        echo $"Restore of Legacy Dokuwiki complete"
191
-    fi
192
-}
193
-
194
 function restore_local_dokuwiki {
147
 function restore_local_dokuwiki {
195
-    if [ -d ${USB_MOUNT}/backup/dokuwiki ]; then
196
-        restore_local_dokuwiki_legacy
197
-        return
198
-    fi
199
-
200
     echo $"Restoring Dokuwiki installation"
148
     echo $"Restoring Dokuwiki installation"
201
     function_check get_completion_param
149
     function_check get_completion_param
202
     DOKUWIKI_DOMAIN_NAME=$(get_completion_param "dokuwiki domain")
150
     DOKUWIKI_DOMAIN_NAME=$(get_completion_param "dokuwiki domain")
205
     temp_restore_dir=/root/tempdokuwikidat
153
     temp_restore_dir=/root/tempdokuwikidat
206
     function_check restore_directory_from_usb
154
     function_check restore_directory_from_usb
207
     restore_directory_from_usb ${temp_restore_dir} dokuwikidat
155
     restore_directory_from_usb ${temp_restore_dir} dokuwikidat
208
-    cp -r ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/data/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data
156
+    if [ -d ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/data ]; then
157
+        cp -r ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/data/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data
158
+    else
159
+        cp -r ${temp_restore_dir}/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data
160
+    fi
209
     if [ ! "$?" = "0" ]; then
161
     if [ ! "$?" = "0" ]; then
210
         function_check restore_directory_from_usb
162
         function_check restore_directory_from_usb
211
         set_user_permissions
163
         set_user_permissions
220
     temp_restore_dir=/root/tempdokuwikiacl
172
     temp_restore_dir=/root/tempdokuwikiacl
221
     function_check restore_directory_from_usb
173
     function_check restore_directory_from_usb
222
     restore_directory_from_usb ${temp_restore_dir} dokuwikiacl
174
     restore_directory_from_usb ${temp_restore_dir} dokuwikiacl
223
-    cp ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/lib/plugins/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/
224
-    cp ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/lib/plugins/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/conf/
175
+    if [ -d ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/lib/plugins/acl ]; then
176
+        cp ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/lib/plugins/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/
177
+        cp ${temp_restore_dir}/var/www/${DOKUWIKI_DOMAIN_NAME}/htdocs/lib/plugins/acl/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/conf/
178
+    else
179
+        cp ${temp_restore_dir}/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/
180
+        cp ${temp_restore_dir}/users.auth.php /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/conf/
181
+    fi
225
     if [ ! "$?" = "0" ]; then
182
     if [ ! "$?" = "0" ]; then
226
         function_check restore_directory_from_usb
183
         function_check restore_directory_from_usb
227
         set_user_permissions
184
         set_user_permissions
257
 
214
 
258
     if [ -d $SERVER_DIRECTORY/backup/dokuwikidat ]; then
215
     if [ -d $SERVER_DIRECTORY/backup/dokuwikidat ]; then
259
         echo $"Restoring Dokuwiki data for $DOKUWIKI_DOMAIN_NAME"
216
         echo $"Restoring Dokuwiki data for $DOKUWIKI_DOMAIN_NAME"
260
-        restore_directory_from_friend /root/tempdokuwikidat dokuwikidat
261
-        cp -r /root/tempdokuwikidat/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data/
217
+        temp_restore_dir=/root/tempdokuwikidat
218
+        restore_directory_from_friend $temp_restore_dir dokuwikidat
219
+        if [ -d $temp_restore_dir/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data ]; then
220
+            cp -r $temp_restore_dir/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data/
221
+        else
222
+            cp -r $temp_restore_dir/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/data/
223
+        fi
262
         if [ ! "$?" = "0" ]; then
224
         if [ ! "$?" = "0" ]; then
263
             exit 92634
225
             exit 92634
264
         fi
226
         fi
265
-        rm -rf /root/tempdokuwikidat
227
+        rm -rf $temp_restore_dir
266
 
228
 
267
         echo $"Restore of Dokuwiki data complete"
229
         echo $"Restore of Dokuwiki data complete"
268
     fi
230
     fi
269
 
231
 
270
     if [ -d $SERVER_DIRECTORY/backup/dokuwikiacl ]; then
232
     if [ -d $SERVER_DIRECTORY/backup/dokuwikiacl ]; then
271
         echo $"Restoring Dokuwiki users for $DOKUWIKI_DOMAIN_NAME"
233
         echo $"Restoring Dokuwiki users for $DOKUWIKI_DOMAIN_NAME"
272
-        restore_directory_from_friend /root/tempdokuwikiacl dokuwikiacl
273
-        cp -r /root/tempdokuwikidat/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/
234
+        temp_restore_dir=/root/tempdokuwikiacl
235
+        restore_directory_from_friend $temp_restore_dir dokuwikiacl
236
+        if [ -d $temp_restore_dir/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl ]; then
237
+            cp -r $temp_restore_dir/var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/
238
+        else
239
+            cp -r $temp_restore_dir/* /var/www/$DOKUWIKI_DOMAIN_NAME/htdocs/lib/plugins/acl/
240
+        fi
274
         if [ ! "$?" = "0" ]; then
241
         if [ ! "$?" = "0" ]; then
275
             exit 735287
242
             exit 735287
276
         fi
243
         fi
277
-        rm -rf /root/tempdokuwikiacl
244
+        rm -rf $temp_restore_dir
278
 
245
 
279
         echo $"Restore of Dokuwiki users complete"
246
         echo $"Restore of Dokuwiki users complete"
280
     fi
247
     fi

+ 26
- 4
src/freedombone-app-emacs 查看文件

81
                 echo $"Restoring Emacs config for $USERNAME"
81
                 echo $"Restoring Emacs config for $USERNAME"
82
                 function_check restore_directory_from_usb
82
                 function_check restore_directory_from_usb
83
                 restore_directory_from_usb $temp_restore_dir emacs/$USERNAME
83
                 restore_directory_from_usb $temp_restore_dir emacs/$USERNAME
84
-                cp -r $temp_restore_dir/home/$USERNAME/.emacs.d /home/$USERNAME/
84
+                if [ -d $temp_restore_dir/home/$USERNAME/.emacs.d ]; then
85
+                    cp -r $temp_restore_dir/home/$USERNAME/.emacs.d /home/$USERNAME/
86
+                else
87
+                    if [ ! -d /home/$USERNAME/.emacs.d ]; then
88
+                        mkdir /home/$USERNAME/.emacs.d
89
+                    fi
90
+                    cp -r $temp_restore_dir/* /home/$USERNAME/.emacs.d
91
+                fi
85
                 if [ ! "$?" = "0" ]; then
92
                 if [ ! "$?" = "0" ]; then
86
                     rm -rf $temp_restore_dir
93
                     rm -rf $temp_restore_dir
87
                     function_check set_user_permissions
94
                     function_check set_user_permissions
90
                     backup_unmount_drive
97
                     backup_unmount_drive
91
                     exit 664
98
                     exit 664
92
                 fi
99
                 fi
93
-                cp -f $temp_restore_dir/home/$USERNAME/.emacs.d/dotemacs /home/$USERNAME/.emacs
100
+                if [ -d $temp_restore_dir/home/$USERNAME/.emacs.d ]; then
101
+                    cp -f $temp_restore_dir/home/$USERNAME/.emacs.d/dotemacs /home/$USERNAME/.emacs
102
+                else
103
+                    cp -f $temp_restore_dir/dotemacs /home/$USERNAME/.emacs
104
+                fi
94
                 rm -rf $temp_restore_dir
105
                 rm -rf $temp_restore_dir
95
             fi
106
             fi
96
         done
107
         done
125
                 echo $"Restoring Emacs config for $USERNAME"
136
                 echo $"Restoring Emacs config for $USERNAME"
126
                 function_check restore_directory_from_friend
137
                 function_check restore_directory_from_friend
127
                 restore_directory_from_friend $temp_restore_dir emacs/$USERNAME
138
                 restore_directory_from_friend $temp_restore_dir emacs/$USERNAME
128
-                cp -r $temp_restore_dir/home/$USERNAME/.emacs.d /home/$USERNAME/
139
+                if [ -d $temp_restore_dir/home/$USERNAME/.emacs.d ]; then
140
+                    cp -r $temp_restore_dir/home/$USERNAME/.emacs.d /home/$USERNAME/
141
+                else
142
+                    if [ ! -d /home/$USERNAME/.emacs.d ]; then
143
+                        mkdir /home/$USERNAME/.emacs.d
144
+                    fi
145
+                    cp -r $temp_restore_dir/* /home/$USERNAME/.emacs.d/*
146
+                fi
129
                 if [ ! "$?" = "0" ]; then
147
                 if [ ! "$?" = "0" ]; then
130
                     rm -rf $temp_restore_dir
148
                     rm -rf $temp_restore_dir
131
                     function_check set_user_permissions
149
                     function_check set_user_permissions
134
                     backup_unmount_drive
152
                     backup_unmount_drive
135
                     exit 664
153
                     exit 664
136
                 fi
154
                 fi
137
-                cp -f $temp_restore_dir/home/$USERNAME/.emacs.d/dotemacs /home/$USERNAME/.emacs
155
+                if [ -d $temp_restore_dir/home/$USERNAME/.emacs.d ]; then
156
+                    cp -f $temp_restore_dir/home/$USERNAME/.emacs.d/dotemacs /home/$USERNAME/.emacs
157
+                else
158
+                    cp -f $temp_restore_dir/dotemacs /home/$USERNAME/.emacs
159
+                fi
138
                 rm -rf $temp_restore_dir
160
                 rm -rf $temp_restore_dir
139
             fi
161
             fi
140
         done
162
         done

+ 10
- 2
src/freedombone-app-ghost 查看文件

251
         function_check restore_directory_from_usb
251
         function_check restore_directory_from_usb
252
         restore_directory_from_usb $temp_restore_dir ghostcontent
252
         restore_directory_from_usb $temp_restore_dir ghostcontent
253
         if [ -d $temp_restore_dir ]; then
253
         if [ -d $temp_restore_dir ]; then
254
-            cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
254
+            if [ -d $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content ]; then
255
+                cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
256
+            else
257
+                cp -r $temp_restore_dir/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
258
+            fi
255
             chown -R ghost:ghost /var/www/$GHOST_DOMAIN_NAME/htdocs/content
259
             chown -R ghost:ghost /var/www/$GHOST_DOMAIN_NAME/htdocs/content
256
             rm -rf $temp_restore_dir
260
             rm -rf $temp_restore_dir
257
         fi
261
         fi
291
     function_check restore_directory_from_friend
295
     function_check restore_directory_from_friend
292
     restore_directory_from_friend $temp_restore_dir ghostcontent
296
     restore_directory_from_friend $temp_restore_dir ghostcontent
293
     if [ -d $temp_restore_dir ]; then
297
     if [ -d $temp_restore_dir ]; then
294
-        cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
298
+        if [ -d $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content ]; then
299
+            cp -r $temp_restore_dir/var/www/$GHOST_DOMAIN_NAME/htdocs/content/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
300
+        else
301
+            cp -r $temp_restore_dir/* /var/www/$GHOST_DOMAIN_NAME/htdocs/content/
302
+        fi
295
         chown -R ghost: /var/www/$GHOST_DOMAIN_NAME/htdocs
303
         chown -R ghost: /var/www/$GHOST_DOMAIN_NAME/htdocs
296
         rm -rf $temp_restore_dir
304
         rm -rf $temp_restore_dir
297
     fi
305
     fi

+ 36
- 6
src/freedombone-app-gnusocial 查看文件

430
         function_check restore_directory_from_usb
430
         function_check restore_directory_from_usb
431
         restore_directory_from_usb $temp_restore_dir gnusocialconfig
431
         restore_directory_from_usb $temp_restore_dir gnusocialconfig
432
         if [ -d $temp_restore_dir ]; then
432
         if [ -d $temp_restore_dir ]; then
433
-            cp $temp_restore_dir$gnusocial_dir/backup/config.php $gnusocial_dir/
433
+            if [ -d cp $temp_restore_dir$gnusocial_dir ]; then
434
+                cp $temp_restore_dir$gnusocial_dir/backup/config.php $gnusocial_dir/
435
+                cp -rp $temp_restore_dir$gnusocial_dir/static $gnusocial_dir/
436
+            else
437
+                cp $temp_restore_dir/backup/config.php $gnusocial_dir/
438
+                if [ ! -d $gnusocial_dir/static ]; then
439
+                    mkdir $gnusocial_dir/static
440
+                fi
441
+                cp -rp $temp_restore_dir/static/* $gnusocial_dir/static/
442
+            fi
434
             chown www-data:www-data $gnusocial_dir/config.php
443
             chown www-data:www-data $gnusocial_dir/config.php
435
-            cp -rp $temp_restore_dir$gnusocial_dir/static $gnusocial_dir/
436
             chown -R www-data:www-data $gnusocial_dir/static
444
             chown -R www-data:www-data $gnusocial_dir/static
437
             rm -rf $temp_restore_dir
445
             rm -rf $temp_restore_dir
438
         fi
446
         fi
439
 
447
 
440
         restore_directory_from_usb $temp_restore_dir gnusocialfile
448
         restore_directory_from_usb $temp_restore_dir gnusocialfile
441
         if [ -d $temp_restore_dir ]; then
449
         if [ -d $temp_restore_dir ]; then
442
-            cp -rp $temp_restore_dir$gnusocial_dir/file $gnusocial_dir/
450
+            if [ -d cp $temp_restore_dir$gnusocial_dir/file ]; then
451
+                cp -rp $temp_restore_dir$gnusocial_dir/file $gnusocial_dir/
452
+            else
453
+                if [ ! -d $gnusocial_dir/file ]; then
454
+                    mkdir $gnusocial_dir/file
455
+                fi
456
+                cp -rp $temp_restore_dir/* $gnusocial_dir/file
457
+            fi
443
             chown -R www-data:www-data $gnusocial_dir/file
458
             chown -R www-data:www-data $gnusocial_dir/file
444
             rm -rf $temp_restore_dir
459
             rm -rf $temp_restore_dir
445
         fi
460
         fi
511
         function_check restore_directory_from_friend
526
         function_check restore_directory_from_friend
512
         restore_directory_from_friend $temp_restore_dir gnusocialconfig
527
         restore_directory_from_friend $temp_restore_dir gnusocialconfig
513
         if [ -d $temp_restore_dir ]; then
528
         if [ -d $temp_restore_dir ]; then
514
-            cp $temp_restore_dir$gnusocial_dir/backup/config.php $gnusocial_dir/
529
+            if [ -d $temp_restore_dir$gnusocial_dir ]; then
530
+                cp $temp_restore_dir$gnusocial_dir/backup/config.php $gnusocial_dir/
531
+                cp -rp $temp_restore_dir$gnusocial_dir/static $gnusocial_dir/
532
+            else
533
+                cp $temp_restore_dir/backup/config.php $gnusocial_dir/
534
+                if [ ! -d $gnusocial_dir/static ]; then
535
+                    mkdir $gnusocial_dir/static
536
+                fi
537
+                cp -rp $temp_restore_dir/static/* $gnusocial_dir/static/
538
+            fi
515
             chown www-data:www-data $gnusocial_dir/config.php
539
             chown www-data:www-data $gnusocial_dir/config.php
516
-            cp -rp $temp_restore_dir$gnusocial_dir/static $gnusocial_dir/
517
             chown -R www-data:www-data $gnusocial_dir/static
540
             chown -R www-data:www-data $gnusocial_dir/static
518
             rm -rf $temp_restore_dir
541
             rm -rf $temp_restore_dir
519
         fi
542
         fi
520
 
543
 
521
         restore_directory_from_friend $temp_restore_dir gnusocialfile
544
         restore_directory_from_friend $temp_restore_dir gnusocialfile
522
         if [ -d $temp_restore_dir ]; then
545
         if [ -d $temp_restore_dir ]; then
523
-            cp -rp $temp_restore_dir$gnusocial_dir/file $gnusocial_dir/
546
+            if [ ! -d $temp_restore_dir$gnusocial_dir/file ]; then
547
+                cp -rp $temp_restore_dir$gnusocial_dir/file $gnusocial_dir/
548
+            else
549
+                if [ ! -d $gnusocial_dir/file ]; then
550
+                    mkdir $gnusocial_dir/file
551
+                fi
552
+                cp -rp $temp_restore_dir/* $gnusocial_dir/file/
553
+            fi
524
             chown -R www-data:www-data $gnusocial_dir/file
554
             chown -R www-data:www-data $gnusocial_dir/file
525
             rm -rf $temp_restore_dir
555
             rm -rf $temp_restore_dir
526
         fi
556
         fi

+ 30
- 6
src/freedombone-app-gogs 查看文件

249
             if [ ! -d /home/${GOGS_USERNAME}/custom ]; then
249
             if [ ! -d /home/${GOGS_USERNAME}/custom ]; then
250
                 mkdir -p /home/${GOGS_USERNAME}/custom
250
                 mkdir -p /home/${GOGS_USERNAME}/custom
251
             fi
251
             fi
252
-            cp -r ${temp_restore_dir}/home/${GOGS_USERNAME}/custom/* /home/${GOGS_USERNAME}/custom
252
+            if [ ! -d ${temp_restore_dir}/home/${GOGS_USERNAME}/custom ]; then
253
+                cp -r ${temp_restore_dir}/home/${GOGS_USERNAME}/custom/* /home/${GOGS_USERNAME}/custom
254
+            else
255
+                cp -r ${temp_restore_dir}/* /home/${GOGS_USERNAME}/custom/
256
+            fi
253
             if [ ! "$?" = "0" ]; then
257
             if [ ! "$?" = "0" ]; then
254
                 function_check set_user_permissions
258
                 function_check set_user_permissions
255
                 set_user_permissions
259
                 set_user_permissions
260
             echo $"Restoring Gogs repos"
264
             echo $"Restoring Gogs repos"
261
             function_check restore_directory_from_usb
265
             function_check restore_directory_from_usb
262
             restore_directory_from_usb ${temp_restore_dir}repos gogsrepos
266
             restore_directory_from_usb ${temp_restore_dir}repos gogsrepos
263
-            cp -r ${temp_restore_dir}repos/home/${GOGS_USERNAME}/gogs-repositories/* /home/${GOGS_USERNAME}/gogs-repositories/
267
+            if [ ! -d ${temp_restore_dir}repos/home/${GOGS_USERNAME}/gogs-repositories ]; then
268
+                cp -r ${temp_restore_dir}repos/home/${GOGS_USERNAME}/gogs-repositories/* /home/${GOGS_USERNAME}/gogs-repositories/
269
+            else
270
+                cp -r ${temp_restore_dir}/* /home/${GOGS_USERNAME}/gogs-repositories/
271
+            fi
264
             if [ ! "$?" = "0" ]; then
272
             if [ ! "$?" = "0" ]; then
265
                 function_check set_user_permissions
273
                 function_check set_user_permissions
266
                 set_user_permissions
274
                 set_user_permissions
274
             if [ ! -d /home/${GOGS_USERNAME}/.ssh ]; then
282
             if [ ! -d /home/${GOGS_USERNAME}/.ssh ]; then
275
                 mkdir /home/${GOGS_USERNAME}/.ssh
283
                 mkdir /home/${GOGS_USERNAME}/.ssh
276
             fi
284
             fi
277
-            cp -r ${temp_restore_dir}ssh/home/${GOGS_USERNAME}/.ssh/* /home/${GOGS_USERNAME}/.ssh/
285
+            if [ -d ${temp_restore_dir}ssh/home/${GOGS_USERNAME}/.ssh ]; then
286
+                cp -r ${temp_restore_dir}ssh/home/${GOGS_USERNAME}/.ssh/* /home/${GOGS_USERNAME}/.ssh/
287
+            else
288
+                cp -r ${temp_restore_dir}/* /home/${GOGS_USERNAME}/.ssh/
289
+            fi
278
             if [ ! "$?" = "0" ]; then
290
             if [ ! "$?" = "0" ]; then
279
                 function_check set_user_permissions
291
                 function_check set_user_permissions
280
                 set_user_permissions
292
                 set_user_permissions
338
             if [ ! -d /home/${GOGS_USERNAME}/custom ]; then
350
             if [ ! -d /home/${GOGS_USERNAME}/custom ]; then
339
                 mkdir -p /home/${GOGS_USERNAME}/custom
351
                 mkdir -p /home/${GOGS_USERNAME}/custom
340
             fi
352
             fi
341
-            cp -r /root/tempgogs/home/${GOGS_USERNAME}/custom/* /home/${GOGS_USERNAME}/custom/
353
+            if [ -d /root/tempgogs/home/${GOGS_USERNAME}/custom ]; then
354
+                cp -r /root/tempgogs/home/${GOGS_USERNAME}/custom/* /home/${GOGS_USERNAME}/custom/
355
+            else
356
+                cp -r /root/tempgogs/* /home/${GOGS_USERNAME}/custom/
357
+            fi
342
             if [ ! "$?" = "0" ]; then
358
             if [ ! "$?" = "0" ]; then
343
                 exit 58852
359
                 exit 58852
344
             fi
360
             fi
345
             echo $"Restoring Gogs repos"
361
             echo $"Restoring Gogs repos"
346
             restore_directory_from_friend /root/tempgogsrepos gogsrepos
362
             restore_directory_from_friend /root/tempgogsrepos gogsrepos
347
-            cp -r /root/tempgogsrepos/home/${GOGS_USERNAME}/gogs-repositories/* /home/${GOGS_USERNAME}/gogs-repositories/
363
+            if [ -d /root/tempgogsrepos/home/${GOGS_USERNAME}/gogs-repositories ]; then
364
+                cp -r /root/tempgogsrepos/home/${GOGS_USERNAME}/gogs-repositories/* /home/${GOGS_USERNAME}/gogs-repositories/
365
+            else
366
+                cp -r /root/tempgogsrepos/* /home/${GOGS_USERNAME}/gogs-repositories/
367
+            fi
348
             if [ ! "$?" = "0" ]; then
368
             if [ ! "$?" = "0" ]; then
349
                 exit 7649
369
                 exit 7649
350
             fi
370
             fi
353
             if [ ! -d /home/${GOGS_USERNAME}/.ssh ]; then
373
             if [ ! -d /home/${GOGS_USERNAME}/.ssh ]; then
354
                 mkdir /home/${GOGS_USERNAME}/.ssh
374
                 mkdir /home/${GOGS_USERNAME}/.ssh
355
             fi
375
             fi
356
-            cp -r /root/tempgogsssh/home/${GOGS_USERNAME}/.ssh/* /home/${GOGS_USERNAME}/.ssh/
376
+            if [ -d /root/tempgogsssh/home/${GOGS_USERNAME}/.ssh ]; then
377
+                cp -r /root/tempgogsssh/home/${GOGS_USERNAME}/.ssh/* /home/${GOGS_USERNAME}/.ssh/
378
+            else
379
+                cp -r /root/tempgogsssh/* /home/${GOGS_USERNAME}/.ssh/
380
+            fi
357
             if [ ! "$?" = "0" ]; then
381
             if [ ! "$?" = "0" ]; then
358
                 exit 74239
382
                 exit 74239
359
             fi
383
             fi

+ 20
- 4
src/freedombone-app-htmly 查看文件

249
             fi
249
             fi
250
             mv /var/www/${HTMLY_DOMAIN_NAME}/htdocs /var/www/${HTMLY_DOMAIN_NAME}/previous
250
             mv /var/www/${HTMLY_DOMAIN_NAME}/htdocs /var/www/${HTMLY_DOMAIN_NAME}/previous
251
         fi
251
         fi
252
-        temp_source_dir=$(find ${temp_restore_dir} -name htdocs)
253
-        cp -r ${temp_source_dir} /var/www/${HTMLY_DOMAIN_NAME}/
252
+        if [ -d ${temp_restore_dir}/var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then
253
+            temp_source_dir=$(find ${temp_restore_dir} -name htdocs)
254
+            cp -r ${temp_source_dir} /var/www/${HTMLY_DOMAIN_NAME}/
255
+        else
256
+            if [ ! -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then
257
+                mkdir /var/www/${HTMLY_DOMAIN_NAME}/htdocs
258
+            fi
259
+            cp -r ${temp_restore_dir}/* /var/www/${HTMLY_DOMAIN_NAME}/htdocs/
260
+        fi
254
         if [ ! "$?" = "0" ]; then
261
         if [ ! "$?" = "0" ]; then
255
             if [ -d /var/www/${HTMLY_DOMAIN_NAME}/previous ]; then
262
             if [ -d /var/www/${HTMLY_DOMAIN_NAME}/previous ]; then
256
                 mv /var/www/${HTMLY_DOMAIN_NAME}/previous /var/www/${HTMLY_DOMAIN_NAME}/htdocs
263
                 mv /var/www/${HTMLY_DOMAIN_NAME}/previous /var/www/${HTMLY_DOMAIN_NAME}/htdocs
315
             fi
322
             fi
316
             mv /var/www/${HTMLY_DOMAIN_NAME}/htdocs /var/www/${HTMLY_DOMAIN_NAME}/previous
323
             mv /var/www/${HTMLY_DOMAIN_NAME}/htdocs /var/www/${HTMLY_DOMAIN_NAME}/previous
317
         fi
324
         fi
318
-        temp_source_dir=$(find ${temp_restore_dir} -name htdocs)
319
-        cp -r ${temp_source_dir} /var/www/${HTMLY_DOMAIN_NAME}/
325
+
326
+        if [ -d ${temp_restore_dir}/var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then
327
+            temp_source_dir=$(find ${temp_restore_dir} -name htdocs)
328
+            cp -r ${temp_source_dir} /var/www/${HTMLY_DOMAIN_NAME}/
329
+        else
330
+            if [ ! -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then
331
+                mkdir /var/www/${HTMLY_DOMAIN_NAME}/htdocs
332
+            fi
333
+            cp -r ${temp_restore_dir}/* /var/www/${HTMLY_DOMAIN_NAME}/htdocs/
334
+        fi
335
+
320
         if [ ! "$?" = "0" ]; then
336
         if [ ! "$?" = "0" ]; then
321
             if [ -d /var/www/${HTMLY_DOMAIN_NAME}/previous ]; then
337
             if [ -d /var/www/${HTMLY_DOMAIN_NAME}/previous ]; then
322
                 mv /var/www/${HTMLY_DOMAIN_NAME}/previous /var/www/${HTMLY_DOMAIN_NAME}/htdocs
338
                 mv /var/www/${HTMLY_DOMAIN_NAME}/previous /var/www/${HTMLY_DOMAIN_NAME}/htdocs

+ 10
- 2
src/freedombone-app-ipfs 查看文件

119
         function_check restore_directory_from_usb
119
         function_check restore_directory_from_usb
120
         restore_directory_from_usb $temp_restore_dir ipfs
120
         restore_directory_from_usb $temp_restore_dir ipfs
121
         ADMIN_USERNAME=$(get_completion_param "Admin user")
121
         ADMIN_USERNAME=$(get_completion_param "Admin user")
122
-        cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
122
+        if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs ]; then
123
+            cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
124
+        else
125
+            cp -rf $temp_restore_dir/* /home/$ADMIN_USERNAME/.ipfs
126
+        fi
123
         if [ ! "$?" = "0" ]; then
127
         if [ ! "$?" = "0" ]; then
124
             rm -rf $temp_restore_dir
128
             rm -rf $temp_restore_dir
125
             function_check set_user_permissions
129
             function_check set_user_permissions
151
         temp_restore_dir=/root/tempipfs
155
         temp_restore_dir=/root/tempipfs
152
         function_check restore_directory_from_friend
156
         function_check restore_directory_from_friend
153
         restore_directory_from_friend $temp_restore_dir ipfs
157
         restore_directory_from_friend $temp_restore_dir ipfs
154
-        cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
158
+        if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs ]; then
159
+            cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
160
+        else
161
+            cp -rf $temp_restore_dir/* /home/$ADMIN_USERNAME/.ipfs
162
+        fi
155
         if [ ! "$?" = "0" ]; then
163
         if [ ! "$?" = "0" ]; then
156
             function_check set_user_permissions
164
             function_check set_user_permissions
157
             set_user_permissions
165
             set_user_permissions

+ 26
- 4
src/freedombone-app-kanboard 查看文件

243
         function_check restore_directory_from_usb
243
         function_check restore_directory_from_usb
244
         restore_directory_from_usb $temp_restore_dir kanboardconfig
244
         restore_directory_from_usb $temp_restore_dir kanboardconfig
245
         if [ -d $temp_restore_dir ]; then
245
         if [ -d $temp_restore_dir ]; then
246
-            cp $temp_restore_dir$kanboard_dir/backup/config.php $kanboard_dir/
246
+            if [ -d $temp_restore_dir$kanboard_dir/backup ]; then
247
+                cp $temp_restore_dir$kanboard_dir/backup/config.php $kanboard_dir/
248
+            else
249
+                cp $temp_restore_dir/config.php $kanboard_dir/
250
+            fi
247
             chown www-data:www-data $kanboard_dir/config.php
251
             chown www-data:www-data $kanboard_dir/config.php
248
             rm -rf $temp_restore_dir
252
             rm -rf $temp_restore_dir
249
         fi
253
         fi
250
 
254
 
251
         restore_directory_from_usb $temp_restore_dir kanboardfile
255
         restore_directory_from_usb $temp_restore_dir kanboardfile
252
         if [ -d $temp_restore_dir ]; then
256
         if [ -d $temp_restore_dir ]; then
253
-            cp -rp $temp_restore_dir$kanboard_dir/data $kanboard_dir/
257
+            if [ -d $temp_restore_dir$kanboard_dir/data ]; then
258
+                cp -rp $temp_restore_dir$kanboard_dir/data $kanboard_dir/
259
+            else
260
+                if [ ! -d $kanboard_dir/data ]; then
261
+                    mkdir $kanboard_dir/data
262
+                fi
263
+                cp -rp $temp_restore_dir/* $kanboard_dir/data/
264
+            fi
254
             chown -R www-data:www-data $kanboard_dir/data
265
             chown -R www-data:www-data $kanboard_dir/data
255
             rm -rf $temp_restore_dir
266
             rm -rf $temp_restore_dir
256
         fi
267
         fi
313
         function_check restore_directory_from_friend
324
         function_check restore_directory_from_friend
314
         restore_directory_from_friend $temp_restore_dir kanboardconfig
325
         restore_directory_from_friend $temp_restore_dir kanboardconfig
315
         if [ -d $temp_restore_dir ]; then
326
         if [ -d $temp_restore_dir ]; then
316
-            cp $temp_restore_dir$kanboard_dir/backup/config.php $kanboard_dir/
327
+            if [ -d $temp_restore_dir$kanboard_dir/backup ]; then
328
+                cp $temp_restore_dir$kanboard_dir/backup/config.php $kanboard_dir/
329
+            else
330
+                cp $temp_restore_dir/config.php $kanboard_dir/
331
+            fi
317
             chown www-data:www-data $kanboard_dir/config.php
332
             chown www-data:www-data $kanboard_dir/config.php
318
             rm -rf $temp_restore_dir
333
             rm -rf $temp_restore_dir
319
         fi
334
         fi
320
 
335
 
321
         restore_directory_from_friend $temp_restore_dir kanboardfile
336
         restore_directory_from_friend $temp_restore_dir kanboardfile
322
         if [ -d $temp_restore_dir ]; then
337
         if [ -d $temp_restore_dir ]; then
323
-            cp -rp $temp_restore_dir$kanboard_dir/data $kanboard_dir/
338
+            if [ -d $temp_restore_dir$kanboard_dir/data ]; then
339
+                cp -rp $temp_restore_dir$kanboard_dir/data $kanboard_dir/
340
+            else
341
+                if [ ! -d $kanboard_dir/data ]; then
342
+                    mkdir $kanboard_dir/data
343
+                fi
344
+                cp -rp $temp_restore_dir/* $kanboard_dir/data/
345
+            fi
324
             chown -R www-data:www-data $kanboard_dir/data
346
             chown -R www-data:www-data $kanboard_dir/data
325
             rm -rf $temp_restore_dir
347
             rm -rf $temp_restore_dir
326
         fi
348
         fi

+ 26
- 4
src/freedombone-app-keyserver 查看文件

202
     temp_restore_dir=/root/tempkeyserverconfig
202
     temp_restore_dir=/root/tempkeyserverconfig
203
     function_check restore_directory_from_usb
203
     function_check restore_directory_from_usb
204
     restore_directory_from_usb $temp_restore_dir keyserverconfig
204
     restore_directory_from_usb $temp_restore_dir keyserverconfig
205
-    cp -r $temp_restore_dir/etc/sks/* /etc/sks/
205
+    if [ -d $temp_restore_dir/etc/sks ]; then
206
+        cp -r $temp_restore_dir/etc/sks/* /etc/sks/
207
+    else
208
+        cp -r $temp_restore_dir/* /etc/sks/
209
+    fi
206
     rm -rf $temp_restore_dir
210
     rm -rf $temp_restore_dir
207
     chown -Rc debian-sks: /etc/sks/sksconf
211
     chown -Rc debian-sks: /etc/sks/sksconf
208
     chown -Rc debian-sks: /etc/sks/mailsync
212
     chown -Rc debian-sks: /etc/sks/mailsync
211
     function_check restore_directory_from_usb
215
     function_check restore_directory_from_usb
212
     restore_directory_from_usb $temp_restore_dir keyserver
216
     restore_directory_from_usb $temp_restore_dir keyserver
213
     mv /var/lib/sks/DB /var/lib/sks/DB_prev
217
     mv /var/lib/sks/DB /var/lib/sks/DB_prev
214
-    cp -r $temp_restore_dir/var/lib/sks/DB /var/lib/sks/DB
218
+    if [ -d $temp_restore_dir/var/lib/sks/DB ]; then
219
+        cp -r $temp_restore_dir/var/lib/sks/DB /var/lib/sks/DB
220
+    else
221
+        if [ ! -d /var/lib/sks/DB ]; then
222
+            mkdir /var/lib/sks/DB
223
+        fi
224
+        cp -r $temp_restore_dir/* /var/lib/sks/DB
225
+    fi
215
     if [ ! "$?" = "0" ]; then
226
     if [ ! "$?" = "0" ]; then
216
         # restore the old database
227
         # restore the old database
217
         rm -rf /var/lib/sks/DB
228
         rm -rf /var/lib/sks/DB
272
     temp_restore_dir=/root/tempkeyserverconfig
283
     temp_restore_dir=/root/tempkeyserverconfig
273
     function_check restore_directory_from_friend
284
     function_check restore_directory_from_friend
274
     restore_directory_from_friend $temp_restore_dir keyserverconfig
285
     restore_directory_from_friend $temp_restore_dir keyserverconfig
275
-    cp -r $temp_restore_dir/etc/sks/* /etc/sks/
286
+    if [ -d $temp_restore_dir/etc/sks ]; then
287
+        cp -r $temp_restore_dir/etc/sks/* /etc/sks/
288
+    else
289
+        cp -r $temp_restore_dir/* /etc/sks/
290
+    fi
276
     rm -rf $temp_restore_dir
291
     rm -rf $temp_restore_dir
277
     chown -Rc debian-sks: /etc/sks/sksconf
292
     chown -Rc debian-sks: /etc/sks/sksconf
278
     chown -Rc debian-sks: /etc/sks/mailsync
293
     chown -Rc debian-sks: /etc/sks/mailsync
281
     function_check restore_directory_from_friend
296
     function_check restore_directory_from_friend
282
     restore_directory_from_friend $temp_restore_dir keyserver
297
     restore_directory_from_friend $temp_restore_dir keyserver
283
     mv /var/lib/sks/DB /var/lib/sks/DB_prev
298
     mv /var/lib/sks/DB /var/lib/sks/DB_prev
284
-    cp -r $temp_restore_dir/var/lib/sks/DB /var/lib/sks/DB
299
+    if [ -d $temp_restore_dir/var/lib/sks/DB ]; then
300
+        cp -r $temp_restore_dir/var/lib/sks/DB /var/lib/sks/DB
301
+    else
302
+        if [ ! -d /var/lib/sks/DB ]; then
303
+            mkdir /var/lib/sks/DB
304
+        fi
305
+        cp -r $temp_restore_dir/* /var/lib/sks/DB
306
+    fi
285
     if [ ! "$?" = "0" ]; then
307
     if [ ! "$?" = "0" ]; then
286
         # restore the old database
308
         # restore the old database
287
         rm -rf /var/lib/sks/DB
309
         rm -rf /var/lib/sks/DB

+ 51
- 4
src/freedombone-app-matrix 查看文件

54
 MATRIX_COMMIT='c45dc6c62aa2a2e83a10d8116a709dfd8c144e3c'
54
 MATRIX_COMMIT='c45dc6c62aa2a2e83a10d8116a709dfd8c144e3c'
55
 REPORT_STATS="no"
55
 REPORT_STATS="no"
56
 MATRIX_SECRET=
56
 MATRIX_SECRET=
57
+MATRIX_EXPIRE_MONTHS=1
57
 
58
 
58
 matrix_variables=(ONION_ONLY
59
 matrix_variables=(ONION_ONLY
59
                   MY_USERNAME
60
                   MY_USERNAME
60
                   MATRIX_SECRET
61
                   MATRIX_SECRET
61
                   DEFAULT_DOMAIN_NAME
62
                   DEFAULT_DOMAIN_NAME
62
                   MATRIX_DOMAIN_NAME
63
                   MATRIX_DOMAIN_NAME
64
+                  MATRIX_EXPIRE_MONTHS
63
                   MATRIX_CODE)
65
                   MATRIX_CODE)
64
 
66
 
67
+function matrix_expire_old_posts {
68
+    read_config_param MY_USERNAME
69
+    read_config_param MATRIX_DOMAIN_NAME
70
+    read_config_param MATRIX_EXPIRE_MONTHS
71
+    read_config_param MATRIX_PORT
72
+
73
+    matrix_remove_posts=/usr/bin/matrix-remove
74
+    echo '#!/bin/bash' > $matrix_remove_posts
75
+    echo "cd $MATRIX_DATA_DIR" >> $matrix_remove_posts
76
+    echo 'ROOM=$1' >> $matrix_remove_posts
77
+    echo "ADMIN=\"@${MY_USERNAME}:$MATRIX_DOMAIN_NAME\"" >> $matrix_remove_posts
78
+    echo "TIME='$MATRIX_EXPIRE_MONTHS months ago'" >> $matrix_remove_posts
79
+    echo "UNIX_TIMESTAMP=\$(date +%s%3N --date='TZ=\"UTC+0\" '\"\$TIME\")" >> $matrix_remove_posts
80
+    echo 'BUSY="pragma busy_timeout=20000"' >> $matrix_remove_posts
81
+    echo "BUFFER=\$(sqlite3 homeserver.db \"\$BUSY;select event_id from events where type='m.room.message' and received_ts<'\$UNIX_TIMESTAMP' and room_id='\$ROOM' order by received_ts desc limit 1;\")" >> $matrix_remove_posts
82
+    echo "EVENT_ID=\$(echo \$BUFFER|awk '{print \$2}')" >> $matrix_remove_posts
83
+
84
+    echo "BUFFER=\$(sqlite3 homeserver.db \"\$BUSY;select token from access_tokens where user_id like '\$ADMIN' order by id desc limit 1;\")" >> $matrix_remove_posts
85
+    echo "TOKEN=\$(echo \$BUFFER|awk '{print \$2}')" >> $matrix_remove_posts
86
+
87
+    echo 'set -x' >> $matrix_remove_posts
88
+    echo "curl -v -X POST 'https://$MATRIX_DOMAIN_NAME/_matrix/client/r0/admin/purge_history/'\$ROOM'/'\$EVENT_ID'?access_token='\$TOKEN" >> $matrix_remove_posts
89
+
90
+    chmod +x $matrix_remove_posts
91
+}
92
+
65
 function logging_on_matrix {
93
 function logging_on_matrix {
66
     if [ -f /var/lib/matrix/homeserver.yaml ]; then
94
     if [ -f /var/lib/matrix/homeserver.yaml ]; then
67
         if ! grep -q "log_file: /etc/matrix/homeserver.log" /var/lib/matrix/homeserver.yaml; then
95
         if ! grep -q "log_file: /etc/matrix/homeserver.log" /var/lib/matrix/homeserver.yaml; then
415
         temp_restore_dir=/root/tempmatrix
443
         temp_restore_dir=/root/tempmatrix
416
         function_check restore_directory_from_usb
444
         function_check restore_directory_from_usb
417
         restore_directory_from_usb $temp_restore_dir matrix
445
         restore_directory_from_usb $temp_restore_dir matrix
418
-        cp -r $temp_restore_dir/etc/matrix/* /etc/matrix
446
+        if [ -d $temp_restore_dir/etc/matrix ]; then
447
+            cp -r $temp_restore_dir/etc/matrix/* /etc/matrix
448
+        else
449
+            cp -r $temp_restore_dir/* /etc/matrix/
450
+        fi
419
         if [ ! "$?" = "0" ]; then
451
         if [ ! "$?" = "0" ]; then
420
             function_check backup_unmount_drive
452
             function_check backup_unmount_drive
421
             backup_unmount_drive
453
             backup_unmount_drive
426
 
458
 
427
         temp_restore_dir=/root/tempmatrixdata
459
         temp_restore_dir=/root/tempmatrixdata
428
         restore_directory_from_usb $temp_restore_dir matrixdata
460
         restore_directory_from_usb $temp_restore_dir matrixdata
429
-        cp -r $temp_restore_dir$MATRIX_DATA_DIR/* $MATRIX_DATA_DIR
461
+        if [ -d $temp_restore_dir$MATRIX_DATA_DIR ]; then
462
+            cp -r $temp_restore_dir$MATRIX_DATA_DIR/* $MATRIX_DATA_DIR
463
+        else
464
+            cp -r $temp_restore_dir/* $MATRIX_DATA_DIR/
465
+        fi
430
         if [ ! "$?" = "0" ]; then
466
         if [ ! "$?" = "0" ]; then
431
             function_check backup_unmount_drive
467
             function_check backup_unmount_drive
432
             backup_unmount_drive
468
             backup_unmount_drive
472
         temp_restore_dir=/root/tempmatrix
508
         temp_restore_dir=/root/tempmatrix
473
         function_check restore_directory_from_friend
509
         function_check restore_directory_from_friend
474
         restore_directory_from_friend $temp_restore_dir matrix
510
         restore_directory_from_friend $temp_restore_dir matrix
475
-        cp -r $temp_restore_dir/etc/matrix/* /etc/matrix
511
+        if [ -d $temp_restore_dir/etc/matrix ]; then
512
+            cp -r $temp_restore_dir/etc/matrix/* /etc/matrix
513
+        else
514
+            cp -r $temp_restore_dir/* /etc/matrix/
515
+        fi
476
         if [ ! "$?" = "0" ]; then
516
         if [ ! "$?" = "0" ]; then
477
             exit 38935
517
             exit 38935
478
         fi
518
         fi
481
 
521
 
482
         temp_restore_dir=/root/tempmatrixdata
522
         temp_restore_dir=/root/tempmatrixdata
483
         restore_directory_from_friend $temp_restore_dir matrixdata
523
         restore_directory_from_friend $temp_restore_dir matrixdata
484
-        cp -r $temp_restore_dir$MATRIX_DATA_DIR/* $MATRIX_DATA_DIR
524
+        if [ -d $temp_restore_dir$MATRIX_DATA_DIR ]; then
525
+            cp -r $temp_restore_dir$MATRIX_DATA_DIR/* $MATRIX_DATA_DIR
526
+        else
527
+            cp -r $temp_restore_dir/* $MATRIX_DATA_DIR/
528
+        fi
485
         if [ ! "$?" = "0" ]; then
529
         if [ ! "$?" = "0" ]; then
486
             exit 60923
530
             exit 60923
487
         fi
531
         fi
635
     fi
679
     fi
636
     chmod -R 700 $MATRIX_DATA_DIR/homeserver.db
680
     chmod -R 700 $MATRIX_DATA_DIR/homeserver.db
637
 
681
 
682
+    cd $MATRIX_DATA_DIR
683
+    sqlite3 homeserver.db "PRAGMA auto_vacuum = FULL;"
684
+
638
     MATRIX_ONION_HOSTNAME=$(add_onion_service matrix ${MATRIX_PORT} ${MATRIX_ONION_PORT})
685
     MATRIX_ONION_HOSTNAME=$(add_onion_service matrix ${MATRIX_PORT} ${MATRIX_ONION_PORT})
639
     echo "HiddenServicePort ${MATRIX_HTTP_PORT} 127.0.0.1:${MATRIX_FEDERATION_ONION_PORT}" >> /etc/tor/torrc
686
     echo "HiddenServicePort ${MATRIX_HTTP_PORT} 127.0.0.1:${MATRIX_FEDERATION_ONION_PORT}" >> /etc/tor/torrc
640
     systemctl restart tor
687
     systemctl restart tor

+ 25
- 8
src/freedombone-app-mediagoblin 查看文件

177
         temp_restore_dir=/root/tempmediagoblin
177
         temp_restore_dir=/root/tempmediagoblin
178
         function_check restore_directory_from_usb
178
         function_check restore_directory_from_usb
179
         restore_directory_from_usb ${temp_restore_dir} mediagoblin
179
         restore_directory_from_usb ${temp_restore_dir} mediagoblin
180
-        cp -r ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR/* $MEDIAGOBLIN_BASE_DIR/
180
+        if [ -d ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR ]; then
181
+            cp -r ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR/* $MEDIAGOBLIN_BASE_DIR/
182
+        else
183
+            cp -r ${temp_restore_dir}/* $MEDIAGOBLIN_BASE_DIR/
184
+        fi
181
         if [ ! "$?" = "0" ]; then
185
         if [ ! "$?" = "0" ]; then
182
             function_check restore_directory_from_usb
186
             function_check restore_directory_from_usb
183
             set_user_permissions
187
             set_user_permissions
186
             exit 45327
190
             exit 45327
187
         fi
191
         fi
188
         restore_directory_from_usb ${temp_restore_dir}2 mediagoblindata
192
         restore_directory_from_usb ${temp_restore_dir}2 mediagoblindata
189
-        cp -r ${temp_restore_dir}2/var/lib/mediagoblin/* /var/lib/mediagoblin/
193
+        if [ -d ${temp_restore_dir}2/var/lib/mediagoblin ]; then
194
+            cp -r ${temp_restore_dir}2/var/lib/mediagoblin/* /var/lib/mediagoblin/
195
+        else
196
+            cp -r ${temp_restore_dir}2/* /var/lib/mediagoblin/
197
+        fi
190
         if [ ! "$?" = "0" ]; then
198
         if [ ! "$?" = "0" ]; then
191
             function_check set_user_permissions
199
             function_check set_user_permissions
192
             set_user_permissions
200
             set_user_permissions
214
 function restore_remote_mediagoblin {
222
 function restore_remote_mediagoblin {
215
     MEDIAGOBLIN_BASE_DIR=/var/www/$MEDIAGOBLIN_DOMAIN_NAME/htdocs
223
     MEDIAGOBLIN_BASE_DIR=/var/www/$MEDIAGOBLIN_DOMAIN_NAME/htdocs
216
     if [ -d $SERVER_DIRECTORY/backup/mediagoblin ]; then
224
     if [ -d $SERVER_DIRECTORY/backup/mediagoblin ]; then
225
+        temp_restore_dir=/root/tempmediagoblin
217
         function_check get_completion_param
226
         function_check get_completion_param
218
         MEDIAGOBLIN_DOMAIN_NAME=$(get_completion_param "mediagoblin domain")
227
         MEDIAGOBLIN_DOMAIN_NAME=$(get_completion_param "mediagoblin domain")
219
         function_check restore_directory_from_friend
228
         function_check restore_directory_from_friend
220
-        restore_directory_from_friend /root/tempmediagoblin mediagoblin
221
-        cp -r /root/tempmediagoblin/var/lib/mediagoblin/* /var/lib/mediagoblin/
229
+        restore_directory_from_friend $temp_restore_dir mediagoblin
230
+        if [ -d ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR ]; then
231
+            cp -r ${temp_restore_dir}$MEDIAGOBLIN_BASE_DIR/* $MEDIAGOBLIN_BASE_DIR/
232
+        else
233
+            cp -r ${temp_restore_dir}/* $MEDIAGOBLIN_BASE_DIR/
234
+        fi
222
         if [ ! "$?" = "0" ]; then
235
         if [ ! "$?" = "0" ]; then
223
             exit 264824
236
             exit 264824
224
         fi
237
         fi
225
-        restore_directory_from_friend /root/tempmediagoblin2 mediagoblindata
226
-        cp -r /root/tempmediagoblin/var/lib/mediagoblin/* /var/lib/mediagoblin/
238
+        restore_directory_from_friend ${temp_restore_dir}2 mediagoblindata
239
+        if [ -d ${temp_restore_dir}2/var/lib/mediagoblin ]; then
240
+            cp -r ${temp_restore_dir}2/var/lib/mediagoblin/* /var/lib/mediagoblin/
241
+        else
242
+            cp -r ${temp_restore_dir}2/* /var/lib/mediagoblin/
243
+        fi
227
         if [ ! "$?" = "0" ]; then
244
         if [ ! "$?" = "0" ]; then
228
             exit 268492
245
             exit 268492
229
         fi
246
         fi
230
-        rm -rf /root/tempmediagoblin
231
-        rm -rf /root/tempmediagoblin2
247
+        rm -rf ${temp_restore_dir}
248
+        rm -rf ${temp_restore_dir}2
232
         chown -hR mediagoblin:www-data $MEDIAGOBLIN_BASE_DIR
249
         chown -hR mediagoblin:www-data $MEDIAGOBLIN_BASE_DIR
233
         chown -hR mediagoblin:www-data /var/lib/mediagoblin
250
         chown -hR mediagoblin:www-data /var/lib/mediagoblin
234
         chmod -R g+wx /var/lib/mediagoblin
251
         chmod -R g+wx /var/lib/mediagoblin

+ 25
- 5
src/freedombone-app-mumble 查看文件

107
         function_check restore_directory_from_usb
107
         function_check restore_directory_from_usb
108
         restore_directory_from_usb $temp_restore_dir voip
108
         restore_directory_from_usb $temp_restore_dir voip
109
         restore_directory_from_usb $temp_restore_dir mumble
109
         restore_directory_from_usb $temp_restore_dir mumble
110
-        cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
110
+        if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
111
+            cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
112
+        else
113
+            cp -f $temp_restore_dir/mumble-server.ini /etc/
114
+        fi
111
         if [ ! "$?" = "0" ]; then
115
         if [ ! "$?" = "0" ]; then
112
             rm -rf $temp_restore_dir
116
             rm -rf $temp_restore_dir
113
             function_check set_user_permissions
117
             function_check set_user_permissions
116
             backup_unmount_drive
120
             backup_unmount_drive
117
             exit 3679
121
             exit 3679
118
         fi
122
         fi
119
-        cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
123
+        if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
124
+            cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
125
+        else
126
+            cp -f $temp_restore_dir/mumble-server.sqlite /var/lib/mumble-server/
127
+        fi
120
         if [ ! "$?" = "0" ]; then
128
         if [ ! "$?" = "0" ]; then
121
             rm -rf $temp_restore_dir
129
             rm -rf $temp_restore_dir
122
             function_check set_user_permissions
130
             function_check set_user_permissions
152
         temp_restore_dir=/root/tempmumble
160
         temp_restore_dir=/root/tempmumble
153
         function_check restore_directory_from_friend
161
         function_check restore_directory_from_friend
154
         restore_directory_from_friend $temp_restore_dir mumble
162
         restore_directory_from_friend $temp_restore_dir mumble
155
-        cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
163
+        if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
164
+            cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.ini /etc/
165
+        else
166
+            cp -f $temp_restore_dir/mumble-server.ini /etc/
167
+        fi
156
         if [ ! "$?" = "0" ]; then
168
         if [ ! "$?" = "0" ]; then
157
             rm -rf $temp_restore_dir
169
             rm -rf $temp_restore_dir
158
             exit 7823
170
             exit 7823
159
         fi
171
         fi
160
-        cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
172
+        if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
173
+            cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
174
+        else
175
+            cp -f $temp_restore_dir/sipwitch.conf /etc/sipwitch.conf
176
+        fi
161
         if [ ! "$?" = "0" ]; then
177
         if [ ! "$?" = "0" ]; then
162
             rm -rf $temp_restore_dir
178
             rm -rf $temp_restore_dir
163
             exit 7823
179
             exit 7823
164
         fi
180
         fi
165
-        cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
181
+        if [ $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
182
+            cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/mumble-server.sqlite /var/lib/mumble-server/
183
+        else
184
+            cp -f $temp_restore_dir/mumble-server.sqlite /var/lib/mumble-server/
185
+        fi
166
         if [ ! "$?" = "0" ]; then
186
         if [ ! "$?" = "0" ]; then
167
             rm -rf $temp_restore_dir
187
             rm -rf $temp_restore_dir
168
             exit 276
188
             exit 276

+ 28
- 8
src/freedombone-app-nextcloud 查看文件

254
 
254
 
255
         temp_restore_dir=/root/tempnextcloudfiles
255
         temp_restore_dir=/root/tempnextcloudfiles
256
         restore_directory_from_usb $temp_restore_dir nextcloudfiles
256
         restore_directory_from_usb $temp_restore_dir nextcloudfiles
257
-        temp_source_dir=$(find ${temp_restore_dir} -name data)
258
-        cp -r ${temp_source_dir} /var/www/${NEXTCLOUD_DOMAIN_NAME}/
257
+
258
+        if [ -d $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data ]; then
259
+            cp -r $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data /var/www/${NEXTCLOUD_DOMAIN_NAME}/
260
+        else
261
+            cp -r $temp_restore_dir/* /var/www/${NEXTCLOUD_DOMAIN_NAME}/
262
+        fi
263
+
259
         if [ ! "$?" = "0" ]; then
264
         if [ ! "$?" = "0" ]; then
260
             set_user_permissions
265
             set_user_permissions
261
             backup_unmount_drive
266
             backup_unmount_drive
265
 
270
 
266
         temp_restore_dir=/root/tempnextcloudconfig
271
         temp_restore_dir=/root/tempnextcloudconfig
267
         restore_directory_from_usb $temp_restore_dir nextcloudconfig
272
         restore_directory_from_usb $temp_restore_dir nextcloudconfig
268
-        temp_source_dir=$(find ${temp_restore_dir} -name config)
269
-        cp -r ${temp_source_dir} /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/
273
+
274
+        if [ -d $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config ]; then
275
+            cp -r $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
276
+        else
277
+            cp -r $temp_restore_dir/* /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/
278
+        fi
279
+
270
         if [ ! "$?" = "0" ]; then
280
         if [ ! "$?" = "0" ]; then
271
             set_user_permissions
281
             set_user_permissions
272
             backup_unmount_drive
282
             backup_unmount_drive
324
 
334
 
325
         temp_restore_dir=/root/tempnextcloudfiles
335
         temp_restore_dir=/root/tempnextcloudfiles
326
         restore_directory_from_friend $temp_restore_dir nextcloudfiles
336
         restore_directory_from_friend $temp_restore_dir nextcloudfiles
327
-        temp_source_dir=$(find ${temp_restore_dir} -name data)
328
-        cp -r ${temp_source_dir} /var/www/${NEXTCLOUD_DOMAIN_NAME}/
337
+
338
+        if [ -d $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data ]; then
339
+            cp -r $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/data /var/www/${NEXTCLOUD_DOMAIN_NAME}/
340
+        else
341
+            cp -r $temp_restore_dir/* /var/www/${NEXTCLOUD_DOMAIN_NAME}/
342
+        fi
343
+
329
         if [ ! "$?" = "0" ]; then
344
         if [ ! "$?" = "0" ]; then
330
             exit 768254
345
             exit 768254
331
         fi
346
         fi
333
 
348
 
334
         temp_restore_dir=/root/tempnextcloudconfig
349
         temp_restore_dir=/root/tempnextcloudconfig
335
         restore_directory_from_friend $temp_restore_dir nextcloudconfig
350
         restore_directory_from_friend $temp_restore_dir nextcloudconfig
336
-        temp_source_dir=$(find ${temp_restore_dir} -name config)
337
-        cp -r ${temp_source_dir} /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/
351
+
352
+        if [ -d $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config ]; then
353
+            cp -r $temp_restore_dir/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs
354
+        else
355
+            cp -r $temp_restore_dir/* /var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/
356
+        fi
357
+
338
         if [ ! "$?" = "0" ]; then
358
         if [ ! "$?" = "0" ]; then
339
             exit 573427
359
             exit 573427
340
         fi
360
         fi

+ 20
- 4
src/freedombone-app-pelican 查看文件

449
             temp_restore_dir=/root/temppelican
449
             temp_restore_dir=/root/temppelican
450
             function_check restore_directory_from_usb
450
             function_check restore_directory_from_usb
451
             restore_directory_from_usb $temp_restore_dir pelican
451
             restore_directory_from_usb $temp_restore_dir pelican
452
-            cp -r $temp_restore_dir/etc/blog/* /etc/blog/
452
+            if [ -d $temp_restore_dir/etc/blog ]; then
453
+                cp -r $temp_restore_dir/etc/blog/* /etc/blog/
454
+            else
455
+                cp -r $temp_restore_dir/* /etc/blog/
456
+            fi
453
             if [ ! "$?" = "0" ]; then
457
             if [ ! "$?" = "0" ]; then
454
                 rm -rf $temp_restore_dir
458
                 rm -rf $temp_restore_dir
455
                 function_check set_user_permissions
459
                 function_check set_user_permissions
466
             temp_restore_dir=/root/temppelican-site
470
             temp_restore_dir=/root/temppelican-site
467
             function_check restore_directory_from_usb
471
             function_check restore_directory_from_usb
468
             restore_directory_from_usb $temp_restore_dir pelican-site
472
             restore_directory_from_usb $temp_restore_dir pelican-site
469
-            cp -r $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
473
+            if [ -d $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs ]; then
474
+                cp -r $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
475
+            else
476
+                cp -r $temp_restore_dir/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
477
+            fi
470
             if [ ! "$?" = "0" ]; then
478
             if [ ! "$?" = "0" ]; then
471
                 rm -rf $temp_restore_dir
479
                 rm -rf $temp_restore_dir
472
                 function_check set_user_permissions
480
                 function_check set_user_permissions
495
             temp_restore_dir=/root/temppelican
503
             temp_restore_dir=/root/temppelican
496
             function_check restore_directory_from_friend
504
             function_check restore_directory_from_friend
497
             restore_directory_from_friend $temp_restore_dir pelican
505
             restore_directory_from_friend $temp_restore_dir pelican
498
-            cp -r $temp_restore_dir/etc/blog/* /etc/blog/
506
+            if [ -d $temp_restore_dir/etc/blog ]; then
507
+                cp -r $temp_restore_dir/etc/blog/* /etc/blog/
508
+            else
509
+                cp -r $temp_restore_dir/* /etc/blog/
510
+            fi
499
             if [ ! "$?" = "0" ]; then
511
             if [ ! "$?" = "0" ]; then
500
                 exit 782352
512
                 exit 782352
501
             fi
513
             fi
507
             temp_restore_dir=/root/temppelican-site
519
             temp_restore_dir=/root/temppelican-site
508
             function_check restore_directory_from_friend
520
             function_check restore_directory_from_friend
509
             restore_directory_from_friend $temp_restore_dir pelican-site
521
             restore_directory_from_friend $temp_restore_dir pelican-site
510
-            cp -r $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
522
+            if [ -d $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs ]; then
523
+                cp -r $temp_restore_dir/var/www/$PELICAN_DOMAIN_NAME/htdocs/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
524
+            else
525
+                cp -r $temp_restore_dir/* /var/www/$PELICAN_DOMAIN_NAME/htdocs/
526
+            fi
511
             if [ ! "$?" = "0" ]; then
527
             if [ ! "$?" = "0" ]; then
512
                 exit 76382562
528
                 exit 76382562
513
             fi
529
             fi

+ 36
- 6
src/freedombone-app-postactiv 查看文件

446
         function_check restore_directory_from_usb
446
         function_check restore_directory_from_usb
447
         restore_directory_from_usb $temp_restore_dir postactivconfig
447
         restore_directory_from_usb $temp_restore_dir postactivconfig
448
         if [ -d $temp_restore_dir ]; then
448
         if [ -d $temp_restore_dir ]; then
449
-            cp $temp_restore_dir$postactiv_dir/backup/config.php $postactiv_dir/
449
+            if [ -d $temp_restore_dir$postactiv_dir ]; then
450
+                cp $temp_restore_dir$postactiv_dir/backup/config.php $postactiv_dir/
451
+                cp -rp $temp_restore_dir$postactiv_dir/static $postactiv_dir/
452
+            else
453
+                cp $temp_restore_dir/backup/config.php $postactiv_dir/
454
+                if [ ! -d $postactiv_dir/static ]; then
455
+                    mkdir $postactiv_dir/static
456
+                fi
457
+                cp -rp $temp_restore_dir/static/* $postactiv_dir/static/
458
+            fi
450
             chown www-data:www-data $postactiv_dir/config.php
459
             chown www-data:www-data $postactiv_dir/config.php
451
-            cp -rp $temp_restore_dir$postactiv_dir/static $postactiv_dir/
452
             chown -R www-data:www-data $postactiv_dir/static
460
             chown -R www-data:www-data $postactiv_dir/static
453
             rm -rf $temp_restore_dir
461
             rm -rf $temp_restore_dir
454
         fi
462
         fi
455
 
463
 
456
         restore_directory_from_usb $temp_restore_dir postactivfile
464
         restore_directory_from_usb $temp_restore_dir postactivfile
457
         if [ -d $temp_restore_dir ]; then
465
         if [ -d $temp_restore_dir ]; then
458
-            cp -rp $temp_restore_dir$postactiv_dir/file $postactiv_dir/
466
+            if [ -d $temp_restore_dir$postactiv_dir/file ]; then
467
+                cp -rp $temp_restore_dir$postactiv_dir/file $postactiv_dir/
468
+            else
469
+                if [ ! -d $postactiv_dir/file ]; then
470
+                    mkdir $postactiv_dir/file
471
+                fi
472
+                cp -rp $temp_restore_dir/* $postactiv_dir/file/
473
+            fi
459
             chown -R www-data:www-data $postactiv_dir/file
474
             chown -R www-data:www-data $postactiv_dir/file
460
             rm -rf $temp_restore_dir
475
             rm -rf $temp_restore_dir
461
         fi
476
         fi
527
         function_check restore_directory_from_friend
542
         function_check restore_directory_from_friend
528
         restore_directory_from_friend $temp_restore_dir postactivconfig
543
         restore_directory_from_friend $temp_restore_dir postactivconfig
529
         if [ -d $temp_restore_dir ]; then
544
         if [ -d $temp_restore_dir ]; then
530
-            cp $temp_restore_dir$postactiv_dir/backup/config.php $postactiv_dir/
545
+            if [ -d $temp_restore_dir$postactiv_dir ]; then
546
+                cp $temp_restore_dir$postactiv_dir/backup/config.php $postactiv_dir/
547
+                cp -rp $temp_restore_dir$postactiv_dir/static $postactiv_dir/
548
+            else
549
+                cp $temp_restore_dir/config.php $postactiv_dir/
550
+                if [ ! -d $postactiv_dir/static ]; then
551
+                    mkdir $postactiv_dir/static
552
+                fi
553
+                cp -rp $temp_restore_dir/static/* $postactiv_dir/static/
554
+            fi
531
             chown www-data:www-data $postactiv_dir/config.php
555
             chown www-data:www-data $postactiv_dir/config.php
532
-            cp -rp $temp_restore_dir$postactiv_dir/static $postactiv_dir/
533
             chown -R www-data:www-data $postactiv_dir/static
556
             chown -R www-data:www-data $postactiv_dir/static
534
             rm -rf $temp_restore_dir
557
             rm -rf $temp_restore_dir
535
         fi
558
         fi
536
 
559
 
537
         restore_directory_from_friend $temp_restore_dir postactivfile
560
         restore_directory_from_friend $temp_restore_dir postactivfile
538
         if [ -d $temp_restore_dir ]; then
561
         if [ -d $temp_restore_dir ]; then
539
-            cp -rp $temp_restore_dir$postactiv_dir/file $postactiv_dir/
562
+            if [ -d $temp_restore_dir$postactiv_dir/file ]; then
563
+                cp -rp $temp_restore_dir$postactiv_dir/file $postactiv_dir/
564
+            else
565
+                if [ ! -d $postactiv_dir/file ]; then
566
+                    mkdir $postactiv_dir/file
567
+                fi
568
+                cp -rp $temp_restore_dir/* $postactiv_dir/file/
569
+            fi
540
             chown -R www-data:www-data $postactiv_dir/file
570
             chown -R www-data:www-data $postactiv_dir/file
541
             rm -rf $temp_restore_dir
571
             rm -rf $temp_restore_dir
542
         fi
572
         fi

+ 20
- 4
src/freedombone-app-radicale 查看文件

214
         temp_restore_dir=/root/tempradicale
214
         temp_restore_dir=/root/tempradicale
215
         function_check restore_directory_from_usb
215
         function_check restore_directory_from_usb
216
         restore_directory_from_usb $temp_restore_dir radicale
216
         restore_directory_from_usb $temp_restore_dir radicale
217
-        cp -r $temp_restore_dir${RADICALE_DIRECTORY}/* ${RADICALE_DIRECTORY}
217
+        if [ -d $temp_restore_dir${RADICALE_DIRECTORY} ]; then
218
+            cp -r $temp_restore_dir${RADICALE_DIRECTORY}/* ${RADICALE_DIRECTORY}
219
+        else
220
+            cp -r $temp_restore_dir/* ${RADICALE_DIRECTORY}/
221
+        fi
218
         if [ ! "$?" = "0" ]; then
222
         if [ ! "$?" = "0" ]; then
219
             function_check backup_unmount_drive
223
             function_check backup_unmount_drive
220
             backup_unmount_drive
224
             backup_unmount_drive
224
 
228
 
225
         temp_restore_dir=/root/tempradicalewww
229
         temp_restore_dir=/root/tempradicalewww
226
         restore_directory_from_usb $temp_restore_dir radicalewww
230
         restore_directory_from_usb $temp_restore_dir radicalewww
227
-        cp -r $temp_restore_dir/var/www/radicale/* /var/www/radicale
231
+        if [ -d $temp_restore_dir/var/www/radicale ]; then
232
+            cp -r $temp_restore_dir/var/www/radicale/* /var/www/radicale
233
+        else
234
+            cp -r $temp_restore_dir/* /var/www/radicale/*
235
+        fi
228
         if [ ! "$?" = "0" ]; then
236
         if [ ! "$?" = "0" ]; then
229
             function_check backup_unmount_drive
237
             function_check backup_unmount_drive
230
             backup_unmount_drive
238
             backup_unmount_drive
251
         temp_restore_dir=/root/tempradicale
259
         temp_restore_dir=/root/tempradicale
252
         function_check restore_directory_from_friend
260
         function_check restore_directory_from_friend
253
         restore_directory_from_friend $temp_restore_dir radicale
261
         restore_directory_from_friend $temp_restore_dir radicale
254
-        cp -r $temp_restore_dir${RADICALE_DIRECTORY}/* ${RADICALE_DIRECTORY}
262
+        if [ -d $temp_restore_dir${RADICALE_DIRECTORY} ]; then
263
+            cp -r $temp_restore_dir${RADICALE_DIRECTORY}/* ${RADICALE_DIRECTORY}
264
+        else
265
+            cp -r $temp_restore_dir/* ${RADICALE_DIRECTORY}/
266
+        fi
255
         if [ ! "$?" = "0" ]; then
267
         if [ ! "$?" = "0" ]; then
256
             exit 236746
268
             exit 236746
257
         fi
269
         fi
259
 
271
 
260
         temp_restore_dir=/root/tempradicalewww
272
         temp_restore_dir=/root/tempradicalewww
261
         restore_directory_from_friend $temp_restore_dir radicalewww
273
         restore_directory_from_friend $temp_restore_dir radicalewww
262
-        cp -r $temp_restore_dir/var/www/radicale/* /var/www/radicale
274
+        if [ -d $temp_restore_dir/var/www/radicale ]; then
275
+            cp -r $temp_restore_dir/var/www/radicale/* /var/www/radicale
276
+        else
277
+            cp -r $temp_restore_dir/* /var/www/radicale
278
+        fi
263
         if [ ! "$?" = "0" ]; then
279
         if [ ! "$?" = "0" ]; then
264
             exit 3674284
280
             exit 3674284
265
         fi
281
         fi

+ 2
- 2
src/freedombone-app-riot 查看文件

33
 IN_DEFAULT_INSTALL=0
33
 IN_DEFAULT_INSTALL=0
34
 SHOW_ON_ABOUT=1
34
 SHOW_ON_ABOUT=1
35
 
35
 
36
-RIOT_VERSION='0.11.4'
36
+RIOT_VERSION='0.12.1'
37
 RIOT_FILENAME="riot-v${RIOT_VERSION}"
37
 RIOT_FILENAME="riot-v${RIOT_VERSION}"
38
-RIOT_HASH='792b8eb398ec08c6f32f64b27f92d31d658c6d2338c1e43c84136f25f64d1cb2'
38
+RIOT_HASH='f6fc2df335af2abcf9fa1329819d20b4d1a0fc8a94a8f087b5f09941f2d5c44a'
39
 RIOT_DOWNLOAD_URL="https://github.com/vector-im/riot-web/releases/download/v${RIOT_VERSION}"
39
 RIOT_DOWNLOAD_URL="https://github.com/vector-im/riot-web/releases/download/v${RIOT_VERSION}"
40
 RIOT_ONION_PORT=8115
40
 RIOT_ONION_PORT=8115
41
 RIOT_ONION_HOSTNAME=
41
 RIOT_ONION_HOSTNAME=

+ 14
- 5
src/freedombone-app-rss 查看文件

171
     restore_database ttrss ${RSS_READER_DOMAIN_NAME}
171
     restore_database ttrss ${RSS_READER_DOMAIN_NAME}
172
 
172
 
173
     if [ -d /etc/share/tt-rss ]; then
173
     if [ -d /etc/share/tt-rss ]; then
174
-        if [ -d /root/tempttrss/etc/share/tt-rss ]; then
175
-            rm -rf /etc/share/tt-rss
176
-            mv /root/tempttrss/etc/share/tt-rss /etc/share/
174
+        if [ -d $temp_restore_dir/etc/share/tt-rss ]; then
175
+            if [ -d $temp_restore_dir/etc/share/tt-rss ]; then
176
+                rm -rf /etc/share/tt-rss
177
+                mv $temp_restore_dir/etc/share/tt-rss /etc/share/
178
+            else
179
+                cp -r $temp_restore_dir/* /etc/share/tt-rss/
180
+            fi
177
             if [ ! "$?" = "0" ]; then
181
             if [ ! "$?" = "0" ]; then
178
                 function_check set_user_permissions
182
                 function_check set_user_permissions
179
                 set_user_permissions
183
                 set_user_permissions
230
 }
234
 }
231
 
235
 
232
 function restore_remote_rss {
236
 function restore_remote_rss {
237
+    temp_restore_dir=/root/tempttrss
233
     if grep -q "rss reader domain" $COMPLETION_FILE; then
238
     if grep -q "rss reader domain" $COMPLETION_FILE; then
234
         echo $"Restoring ttrss"
239
         echo $"Restoring ttrss"
235
         function_check restore_database_from_friend
240
         function_check restore_database_from_friend
240
         restore_database_from_friend ttrss ${RSS_READER_DOMAIN_NAME}
245
         restore_database_from_friend ttrss ${RSS_READER_DOMAIN_NAME}
241
 
246
 
242
         if [ -d /etc/share/tt-rss ]; then
247
         if [ -d /etc/share/tt-rss ]; then
243
-            rm -rf /etc/share/tt-rss
244
-            mv /root/tempttrss/etc/share/tt-rss /etc/share/
248
+            if [ -d $temp_restore_dir/etc/share/tt-rss ]; then
249
+                rm -rf /etc/share/tt-rss
250
+                mv $temp_restore_dir/etc/share/tt-rss /etc/share/
251
+            else
252
+                cp -r $temp_restore_dir/* /etc/share/tt-rss/
253
+            fi
245
             if [ ! "$?" = "0" ]; then
254
             if [ ! "$?" = "0" ]; then
246
                 exit 6391
255
                 exit 6391
247
             fi
256
             fi

+ 12
- 2
src/freedombone-app-scuttlebot 查看文件

144
         temp_restore_dir=/root/tempscuttlebot
144
         temp_restore_dir=/root/tempscuttlebot
145
         function_check restore_directory_from_usb
145
         function_check restore_directory_from_usb
146
         restore_directory_from_usb $temp_restore_dir scuttlebot
146
         restore_directory_from_usb $temp_restore_dir scuttlebot
147
-        cp -r $temp_restore_dir/etc/scuttlebot/.ssb /etc/scuttlebot/
147
+        if [ -d $temp_restore_dir/etc/scuttlebot/.ssb ]; then
148
+            cp -r $temp_restore_dir/etc/scuttlebot/.ssb /etc/scuttlebot/
149
+        else
150
+            cp -r $temp_restore_dir/* /etc/scuttlebot/.ssb/*
151
+        fi
148
         systemctl start scuttlebot
152
         systemctl start scuttlebot
153
+        rm -rf $temp_restore_dir
149
     fi
154
     fi
150
 }
155
 }
151
 
156
 
164
         temp_restore_dir=/root/tempscuttlebot
169
         temp_restore_dir=/root/tempscuttlebot
165
         function_check restore_directory_from_friend
170
         function_check restore_directory_from_friend
166
         restore_directory_from_friend $temp_restore_dir scuttlebot
171
         restore_directory_from_friend $temp_restore_dir scuttlebot
167
-        cp -r $temp_restore_dir/etc/scuttlebot/.ssb /etc/scuttlebot/
172
+        if [ -d $temp_restore_dir/etc/scuttlebot/.ssb ]; then
173
+            cp -r $temp_restore_dir/etc/scuttlebot/.ssb /etc/scuttlebot/
174
+        else
175
+            cp -r $temp_restore_dir/* /etc/scuttlebot/.ssb/*
176
+        fi
168
         systemctl start scuttlebot
177
         systemctl start scuttlebot
178
+        rm -rf $temp_restore_dir
169
     fi
179
     fi
170
 }
180
 }
171
 
181
 

+ 22
- 2
src/freedombone-app-sip 查看文件

145
         temp_restore_dir=/root/tempsip
145
         temp_restore_dir=/root/tempsip
146
         function_check restore_directory_from_usb
146
         function_check restore_directory_from_usb
147
         restore_directory_from_usb $temp_restore_dir sip
147
         restore_directory_from_usb $temp_restore_dir sip
148
-        cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
148
+        if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
149
+            cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
150
+        else
151
+            cp -f $temp_restore_dir/sipwitch.conf /etc/sipwitch.conf
152
+        fi
149
         if [ ! "$?" = "0" ]; then
153
         if [ ! "$?" = "0" ]; then
150
             rm -rf $temp_restore_dir
154
             rm -rf $temp_restore_dir
151
             function_check set_user_permissions
155
             function_check set_user_permissions
173
 }
177
 }
174
 
178
 
175
 function restore_remote_sip {
179
 function restore_remote_sip {
176
-    echo -n ''
180
+    temp_restore_dir=/root/tempsip
181
+    function_check restore_directory_from_friend
182
+    restore_directory_from_friend $temp_restore_dir sip
183
+    if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
184
+        cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/sipwitch.conf /etc/sipwitch.conf
185
+    else
186
+        cp -f $temp_restore_dir/sipwitch.conf /etc/sipwitch.conf
187
+    fi
188
+    if [ ! "$?" = "0" ]; then
189
+        rm -rf $temp_restore_dir
190
+        function_check set_user_permissions
191
+        set_user_permissions
192
+        backup_unmount_drive
193
+        exit 3679
194
+    fi
195
+    rm -rf $temp_restore_dir
196
+    systemctl restart sipwitch
177
 }
197
 }
178
 
198
 
179
 function remove_sip {
199
 function remove_sip {

+ 34
- 6
src/freedombone-app-syncthing 查看文件

286
         echo $"Restoring syncthing configuration"
286
         echo $"Restoring syncthing configuration"
287
         function_check restore_directory_from_usb
287
         function_check restore_directory_from_usb
288
         restore_directory_from_usb ${temp_restore_dir}config syncthingconfig
288
         restore_directory_from_usb ${temp_restore_dir}config syncthingconfig
289
-        cp -r ${temp_restore_dir}config/* /
289
+        #cp -r ${temp_restore_dir}config/* /
290
+
291
+        if [ ! -d /root/.config/syncthing ]; then
292
+            mkdir -p /root/.config/syncthing
293
+        fi
294
+        cp -r ${temp_restore_dir}config/* /root/.config/syncthing/
295
+
290
         if [ ! "$?" = "0" ]; then
296
         if [ ! "$?" = "0" ]; then
291
             set_user_permissions
297
             set_user_permissions
292
             backup_unmount_drive
298
             backup_unmount_drive
300
     if [ -d $USB_MOUNT/backup/syncthingshared ]; then
306
     if [ -d $USB_MOUNT/backup/syncthingshared ]; then
301
         echo $"Restoring syncthing shared files"
307
         echo $"Restoring syncthing shared files"
302
         restore_directory_from_usb ${temp_restore_dir}shared syncthingshared
308
         restore_directory_from_usb ${temp_restore_dir}shared syncthingshared
303
-        cp -r ${temp_restore_dir}shared/* /
309
+        #cp -r ${temp_restore_dir}shared/* /
310
+
311
+        if [ ! -d /var/lib/syncthing/SyncShared ]; then
312
+            mkdir -p /var/lib/syncthing/SyncShared
313
+        fi
314
+        cp -r ${temp_restore_dir}shared/* /var/lib/syncthing/SyncShared/
315
+
304
         if [ ! "$?" = "0" ]; then
316
         if [ ! "$?" = "0" ]; then
305
             set_user_permissions
317
             set_user_permissions
306
             backup_unmount_drive
318
             backup_unmount_drive
320
                 fi
332
                 fi
321
                 echo $"Restoring syncthing files for $USERNAME"
333
                 echo $"Restoring syncthing files for $USERNAME"
322
                 restore_directory_from_usb ${temp_restore_dir} syncthing/$USERNAME
334
                 restore_directory_from_usb ${temp_restore_dir} syncthing/$USERNAME
323
-                cp -r ${temp_restore_dir}/home/$USERNAME/Sync /home/$USERNAME/
335
+                if [ -d ${temp_restore_dir}/home/$USERNAME/Sync ]; then
336
+                    cp -r ${temp_restore_dir}/home/$USERNAME/Sync /home/$USERNAME/
337
+                else
338
+                    cp -r ${temp_restore_dir}/* /home/$USERNAME/Sync/
339
+                fi
324
                 if [ ! "$?" = "0" ]; then
340
                 if [ ! "$?" = "0" ]; then
325
                     rm -rf ${temp_restore_dir}
341
                     rm -rf ${temp_restore_dir}
326
                     set_user_permissions
342
                     set_user_permissions
399
         temp_restore_dir=/root/tempsyncthingconfig
415
         temp_restore_dir=/root/tempsyncthingconfig
400
         function_check restore_directory_from_friend
416
         function_check restore_directory_from_friend
401
         restore_directory_from_friend $temp_restore_dir syncthingconfig
417
         restore_directory_from_friend $temp_restore_dir syncthingconfig
402
-        cp -r $temp_restore_dir/* /
418
+        #cp -r $temp_restore_dir/* /
419
+        if [ ! -d /root/.config/syncthing ]; then
420
+            mkdir -p /root/.config/syncthing
421
+        fi
422
+        cp -r ${temp_restore_dir}config/* /root/.config/syncthing/
403
         if [ ! "$?" = "0" ]; then
423
         if [ ! "$?" = "0" ]; then
404
             systemctl start syncthing
424
             systemctl start syncthing
405
             systemctl start cron
425
             systemctl start cron
413
         temp_restore_dir=/root/tempsyncthingshared
433
         temp_restore_dir=/root/tempsyncthingshared
414
         function_check restore_directory_from_friend
434
         function_check restore_directory_from_friend
415
         restore_directory_from_friend $temp_restore_dir syncthingshared
435
         restore_directory_from_friend $temp_restore_dir syncthingshared
416
-        cp -r $temp_restore_dir/* /
436
+        #cp -r $temp_restore_dir/* /
437
+        if [ ! -d /var/lib/syncthing/SyncShared ]; then
438
+            mkdir -p /var/lib/syncthing/SyncShared
439
+        fi
440
+        cp -r ${temp_restore_dir}shared/* /var/lib/syncthing/SyncShared/
417
         if [ ! "$?" = "0" ]; then
441
         if [ ! "$?" = "0" ]; then
418
             systemctl start syncthing
442
             systemctl start syncthing
419
             systemctl start cron
443
             systemctl start cron
433
                 temp_restore_dir=/root/tempsyncthing
457
                 temp_restore_dir=/root/tempsyncthing
434
                 function_check restore_directory_from_friend
458
                 function_check restore_directory_from_friend
435
                 restore_directory_from_friend $temp_restore_dir syncthing/$USERNAME
459
                 restore_directory_from_friend $temp_restore_dir syncthing/$USERNAME
436
-                cp -r $temp_restore_dir/home/$USERNAME/Sync /home/$USERNAME/
460
+                if [ -d $temp_restore_dir/home/$USERNAME/Sync ]; then
461
+                    cp -r $temp_restore_dir/home/$USERNAME/Sync /home/$USERNAME/
462
+                else
463
+                    cp -r $temp_restore_dir/* /home/$USERNAME/Sync/
464
+                fi
437
                 if [ ! "$?" = "0" ]; then
465
                 if [ ! "$?" = "0" ]; then
438
                     rm -rf $temp_restore_dir
466
                     rm -rf $temp_restore_dir
439
                     systemctl start syncthing
467
                     systemctl start syncthing

+ 26
- 8
src/freedombone-app-tahoelafs 查看文件

298
     systemctl stop tahoelafs-client
298
     systemctl stop tahoelafs-client
299
     temp_restore_dir=/root/temptahoelafs
299
     temp_restore_dir=/root/temptahoelafs
300
     restore_directory_from_usb $temp_restore_dir tahoelafs
300
     restore_directory_from_usb $temp_restore_dir tahoelafs
301
-    mv $TAHOE_DIR ${TAHOE_DIR}-old
302
-    cp -r $temp_restore_dir$TAHOE_DIR $TAHOE_DIR
301
+    if [ -d $temp_restore_dir$TAHOE_DIR ]; then
302
+        mv $TAHOE_DIR ${TAHOE_DIR}-old
303
+        cp -r $temp_restore_dir$TAHOE_DIR $TAHOE_DIR
304
+    else
305
+        cp -r $temp_restore_dir/* $TAHOE_DIR/
306
+    fi
303
     if [ ! "$?" = "0" ]; then
307
     if [ ! "$?" = "0" ]; then
304
-        mv ${TAHOE_DIR}-old $TAHOE_DIR
308
+        if [ -d ${TAHOE_DIR}-old ]; then
309
+            mv ${TAHOE_DIR}-old $TAHOE_DIR
310
+        fi
305
         exit 246833
311
         exit 246833
306
     fi
312
     fi
307
-    rm -rf ${TAHOE_DIR}-old
313
+    if [ -d ${TAHOE_DIR}-old ]; then
314
+        rm -rf ${TAHOE_DIR}-old
315
+    fi
316
+    rm -rf $temp_restore_dir
308
     chown -R tahoelafs:debian-tor $TAHOE_DIR
317
     chown -R tahoelafs:debian-tor $TAHOE_DIR
309
     systemctl start tahoelafs-client
318
     systemctl start tahoelafs-client
310
     systemctl start tahoelafs-storage
319
     systemctl start tahoelafs-storage
331
     systemctl stop tahoelafs-client
340
     systemctl stop tahoelafs-client
332
     temp_restore_dir=/root/temptahoelafs
341
     temp_restore_dir=/root/temptahoelafs
333
     restore_directory_from_friend $temp_restore_dir tahoelafs
342
     restore_directory_from_friend $temp_restore_dir tahoelafs
334
-    mv $TAHOE_DIR ${TAHOE_DIR}-old
335
-    cp -r $temp_restore_dir$TAHOE_DIR $TAHOE_DIR
343
+    if [ -d $temp_restore_dir$TAHOE_DIR ]; then
344
+        mv $TAHOE_DIR ${TAHOE_DIR}-old
345
+        cp -r $temp_restore_dir$TAHOE_DIR $TAHOE_DIR
346
+    else
347
+        cp -r $temp_restore_dir/* $TAHOE_DIR/
348
+    fi
336
     if [ ! "$?" = "0" ]; then
349
     if [ ! "$?" = "0" ]; then
337
-        mv ${TAHOE_DIR}old $TAHOE_DIR
350
+        if [ -d ${$TAHOE_DIR}-old ]; then
351
+            mv ${TAHOE_DIR}-old $TAHOE_DIR
352
+        fi
338
         exit 623925
353
         exit 623925
339
     fi
354
     fi
340
-    rm -rf ${$TAHOE_DIR}-old
355
+    if [ -d ${$TAHOE_DIR}-old ]; then
356
+        rm -rf ${$TAHOE_DIR}-old
357
+    fi
358
+    rm -rf $temp_restore_dir
341
     chown -R tahoelafs:debian-tor $TAHOE_DIR
359
     chown -R tahoelafs:debian-tor $TAHOE_DIR
342
     systemctl start tahoelafs-client
360
     systemctl start tahoelafs-client
343
     systemctl start tahoelafs-storage
361
     systemctl start tahoelafs-storage

+ 4
- 2
src/freedombone-app-tox 查看文件

213
     if [ -d $USB_MOUNT/backup/tox ]; then
213
     if [ -d $USB_MOUNT/backup/tox ]; then
214
         echo $"Restoring Tox node settings"
214
         echo $"Restoring Tox node settings"
215
         function_check restore_directory_from_usb
215
         function_check restore_directory_from_usb
216
-        restore_directory_from_usb / tox
216
+        #restore_directory_from_usb / tox
217
+        restore_directory_from_usb /var/lib/tox-bootstrapd tox
217
         if [ ! "$?" = "0" ]; then
218
         if [ ! "$?" = "0" ]; then
218
             function_check set_user_permissions
219
             function_check set_user_permissions
219
             set_user_permissions
220
             set_user_permissions
250
     if [ -d $SERVER_DIRECTORY/backup/tox ]; then
251
     if [ -d $SERVER_DIRECTORY/backup/tox ]; then
251
         echo $"Restoring Tox node settings"
252
         echo $"Restoring Tox node settings"
252
         function_check restore_directory_from_friend
253
         function_check restore_directory_from_friend
253
-        restore_directory_from_friend / tox
254
+        #restore_directory_from_friend / tox
255
+        restore_directory_from_friend /var/lib/tox-bootstrapd tox
254
         if [ ! "$?" = "0" ]; then
256
         if [ ! "$?" = "0" ]; then
255
             exit 93653
257
             exit 93653
256
         fi
258
         fi

+ 26
- 37
src/freedombone-app-turtl 查看文件

249
     if [ $TURTL_DOMAIN_NAME ]; then
249
     if [ $TURTL_DOMAIN_NAME ]; then
250
         temp_restore_dir=/root/tempturtl
250
         temp_restore_dir=/root/tempturtl
251
         restore_directory_from_usb $temp_restore_dir turtl
251
         restore_directory_from_usb $temp_restore_dir turtl
252
-        if [ -d $TURTL_BASE_DIR ]; then
253
-            if [ -d /etc/turtl_previous ]; then
254
-                rm -rf /etc/turtl_previous
255
-            fi
256
-            mv $TURTL_BASE_DIR /etc/turtl_previous
252
+
253
+        if [ -d ${temp_restore_dir}/etc/turtl ]; then
254
+            cp -r ${temp_restore_dir}/etc/turtl/* /etc/turtl/
255
+        else
256
+            cp -r ${temp_restore_dir}/* /etc/turtl/
257
         fi
257
         fi
258
-        temp_source_dir=$(find ${temp_restore_dir} -name turtl)
259
-        cp -r ${temp_source_dir} /etc/
258
+
260
         if [ ! "$?" = "0" ]; then
259
         if [ ! "$?" = "0" ]; then
261
-            if [ -d /etc/turtl_previous ]; then
262
-                mv /etc/turtl_previous $TURTL_BASE_DIR
263
-            fi
264
             set_user_permissions
260
             set_user_permissions
265
             backup_unmount_drive
261
             backup_unmount_drive
266
             exit 36723
262
             exit 36723
270
 
266
 
271
         temp_restore_dir=/root/temprethinkdb
267
         temp_restore_dir=/root/temprethinkdb
272
         restore_directory_from_usb $temp_restore_dir rethinkdb
268
         restore_directory_from_usb $temp_restore_dir rethinkdb
273
-        if [ -d /var/lib/rethinkdb ]; then
274
-            if [ -d /var/lib/previous_rethinkdb ]; then
275
-                rm -rf /var/lib/previous_rethinkdb
276
-            fi
277
-            mv /var/lib/rethinkdb /var/lib/previous_rethinkdb
269
+
270
+        if [ -d ${temp_restore_dir}/var/lib/rethinkdb ]; then
271
+            cp -r ${temp_restore_dir}/var/lib/rethinkdb/* /var/lib/rethinkdb/
272
+        else
273
+            cp -r ${temp_restore_dir}/* /var/lib/rethinkdb/
278
         fi
274
         fi
279
-        temp_source_dir=$(find ${temp_restore_dir} -name rethinkdb)
280
-        cp -r ${temp_source_dir} /var/lib/
275
+
281
         if [ ! "$?" = "0" ]; then
276
         if [ ! "$?" = "0" ]; then
282
-            if [ -d /var/lib/previous_rethinkdb ]; then
283
-                mv /var/lib/previous_rethinkdb /var/lib/rethinkdb
284
-            fi
285
             set_user_permissions
277
             set_user_permissions
286
             backup_unmount_drive
278
             backup_unmount_drive
287
             exit 378324
279
             exit 378324
319
         mkdir $temp_restore_dir
311
         mkdir $temp_restore_dir
320
         function_check restore_directory_from_friend
312
         function_check restore_directory_from_friend
321
         restore_directory_from_friend $temp_restore_dir turtl
313
         restore_directory_from_friend $temp_restore_dir turtl
322
-        if [ -d $TURTL_BASE_DIR ]; then
323
-            if [ -d /etc/turtl_previous ]; then
324
-                rm -rf /etc/turtl_previous
325
-            fi
326
-            mv $TURTL_BASE_DIR /etc/turtl_previous
314
+
315
+        if [ -d ${temp_restore_dir}/etc/turtl ]; then
316
+            cp -r ${temp_restore_dir}/etc/turtl/* /etc/turtl/
317
+        else
318
+            cp -r ${temp_restore_dir}/* /etc/turtl/
327
         fi
319
         fi
328
-        temp_source_dir=$(find ${temp_restore_dir} -name turtl)
329
-        cp -r ${temp_source_dir} /etc/
320
+
330
         if [ ! "$?" = "0" ]; then
321
         if [ ! "$?" = "0" ]; then
331
             if [ -d /etc/turtl_previous ]; then
322
             if [ -d /etc/turtl_previous ]; then
332
                 mv /etc/turtl_previous $TURTL_BASE_DIR
323
                 mv /etc/turtl_previous $TURTL_BASE_DIR
333
             fi
324
             fi
325
+            set_user_permissions
334
             exit 37823
326
             exit 37823
335
         fi
327
         fi
336
         rm -rf ${temp_restore_dir}
328
         rm -rf ${temp_restore_dir}
339
         mkdir $temp_restore_dir
331
         mkdir $temp_restore_dir
340
         function_check restore_directory_from_friend
332
         function_check restore_directory_from_friend
341
         restore_directory_from_friend $temp_restore_dir rethinkdb
333
         restore_directory_from_friend $temp_restore_dir rethinkdb
342
-        if [ -d /var/lib/rethinkdb ]; then
343
-            if [ -d /var/lib/previous_rethinkdb ]; then
344
-                rm -rf /var/lib/previous_rethinkdb
345
-            fi
346
-            mv /var/lib/rethinkdb /var/lib/previous_rethinkdb
334
+
335
+        if [ -d ${temp_restore_dir}/var/lib/rethinkdb ]; then
336
+            cp -r ${temp_restore_dir}/var/lib/rethinkdb/* /var/lib/rethinkdb/
337
+        else
338
+            cp -r ${temp_restore_dir}/* /var/lib/rethinkdb/
347
         fi
339
         fi
348
-        temp_source_dir=$(find ${temp_restore_dir} -name rethinkdb)
349
-        cp -r ${temp_source_dir} /var/lib/
340
+
350
         if [ ! "$?" = "0" ]; then
341
         if [ ! "$?" = "0" ]; then
351
-            if [ -d /var/lib/previous_rethinkdb ]; then
352
-                mv /var/lib/previous_rethinkdb /var/lib/rethinkdb
353
-            fi
342
+            set_user_permissions
354
             exit 26783
343
             exit 26783
355
         fi
344
         fi
356
         rm -rf ${temp_restore_dir}
345
         rm -rf ${temp_restore_dir}

+ 16
- 2
src/freedombone-app-vim 查看文件

100
                 echo $"Restoring Vim config for $USERNAME"
100
                 echo $"Restoring Vim config for $USERNAME"
101
                 function_check restore_directory_from_usb
101
                 function_check restore_directory_from_usb
102
                 restore_directory_from_usb $temp_restore_dir vim/$USERNAME
102
                 restore_directory_from_usb $temp_restore_dir vim/$USERNAME
103
-                cp -r $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR /home/$USERNAME/
103
+                if [ -d $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR ]; then
104
+                    cp -r $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR /home/$USERNAME/
105
+                else
106
+                    if [ ! -d /home/$USERNAME/$VIM_TEMP_DIR ]; then
107
+                        mkdir /home/$USERNAME/$VIM_TEMP_DIR
108
+                    fi
109
+                    cp -r $temp_restore_dir/* /home/$USERNAME/$VIM_TEMP_DIR/
110
+                fi
104
                 if [ ! "$?" = "0" ]; then
111
                 if [ ! "$?" = "0" ]; then
105
                     rm -rf $temp_restore_dir
112
                     rm -rf $temp_restore_dir
106
                     function_check set_user_permissions
113
                     function_check set_user_permissions
168
                 echo $"Restoring Vim config for $USERNAME"
175
                 echo $"Restoring Vim config for $USERNAME"
169
                 function_check restore_directory_from_friend
176
                 function_check restore_directory_from_friend
170
                 restore_directory_from_friend $temp_restore_dir vim/$USERNAME
177
                 restore_directory_from_friend $temp_restore_dir vim/$USERNAME
171
-                cp -r $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR /home/$USERNAME/
178
+                if [ -d $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR ]; then
179
+                    cp -r $temp_restore_dir/home/$USERNAME/$VIM_TEMP_DIR /home/$USERNAME/
180
+                else
181
+                    if [ ! -d /home/$USERNAME/$VIM_TEMP_DIR ]; then
182
+                        mkdir /home/$USERNAME/$VIM_TEMP_DIR
183
+                    fi
184
+                    cp -r $temp_restore_dir/* /home/$USERNAME/$VIM_TEMP_DIR/
185
+                fi
172
                 if [ ! "$?" = "0" ]; then
186
                 if [ ! "$?" = "0" ]; then
173
                     rm -rf $temp_restore_dir
187
                     rm -rf $temp_restore_dir
174
                     function_check set_user_permissions
188
                     function_check set_user_permissions

+ 12
- 4
src/freedombone-app-wekan 查看文件

134
         temp_restore_dir=/root/tempwekan
134
         temp_restore_dir=/root/tempwekan
135
         function_check restore_directory_from_usb
135
         function_check restore_directory_from_usb
136
         restore_directory_from_usb $temp_restore_dir wekan
136
         restore_directory_from_usb $temp_restore_dir wekan
137
-        cp -r $temp_restore_dir$WEKAN_DIR/data/* $WEKAN_DIR/data/
138
-
137
+        if [ -d $temp_restore_dir$WEKAN_DIR/data ]; then
138
+            cp -r $temp_restore_dir$WEKAN_DIR/data/* $WEKAN_DIR/data/
139
+        else
140
+            cp -r $temp_restore_dir/* $WEKAN_DIR/data/
141
+        fi
142
+        rm -rf $temp_restore_dir
139
         systemctl start wekan
143
         systemctl start wekan
140
     fi
144
     fi
141
 }
145
 }
177
         temp_restore_dir=/root/tempwekan
181
         temp_restore_dir=/root/tempwekan
178
         function_check restore_directory_from_usb
182
         function_check restore_directory_from_usb
179
         restore_directory_from_friend $temp_restore_dir wekan
183
         restore_directory_from_friend $temp_restore_dir wekan
180
-        cp -r $temp_restore_dir$WEKAN_DIR/data/* $WEKAN_DIR/data/
181
-
184
+        if [ -d $temp_restore_dir$WEKAN_DIR/data ]; then
185
+            cp -r $temp_restore_dir$WEKAN_DIR/data/* $WEKAN_DIR/data/
186
+        else
187
+            cp -r $temp_restore_dir/* $WEKAN_DIR/data/
188
+        fi
189
+        rm -rf $temp_restore_dir
182
         systemctl start wekan
190
         systemctl start wekan
183
     fi
191
     fi
184
 }
192
 }

+ 10
- 2
src/freedombone-app-xmpp 查看文件

460
         temp_restore_dir=/root/tempxmpp
460
         temp_restore_dir=/root/tempxmpp
461
         function_check restore_directory_from_usb
461
         function_check restore_directory_from_usb
462
         restore_directory_from_usb $temp_restore_dir xmpp
462
         restore_directory_from_usb $temp_restore_dir xmpp
463
-        cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
463
+        if [ -d $temp_restore_dir/var/lib/prosody ]; then
464
+            cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
465
+        else
466
+            cp -r $temp_restore_dir/* /var/lib/prosody/
467
+        fi
464
         if [ ! "$?" = "0" ]; then
468
         if [ ! "$?" = "0" ]; then
465
             function_check set_user_permissions
469
             function_check set_user_permissions
466
             set_user_permissions
470
             set_user_permissions
489
         temp_restore_dir=/root/tempxmpp
493
         temp_restore_dir=/root/tempxmpp
490
         function_check restore_directory_from_friend
494
         function_check restore_directory_from_friend
491
         restore_directory_from_friend $temp_restore_dir xmpp
495
         restore_directory_from_friend $temp_restore_dir xmpp
492
-        cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
496
+        if [ -d $temp_restore_dir/var/lib/prosody ]; then
497
+            cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
498
+        else
499
+            cp -r $temp_restore_dir/* /var/lib/prosody/
500
+        fi
493
         if [ ! "$?" = "0" ]; then
501
         if [ ! "$?" = "0" ]; then
494
             exit 725
502
             exit 725
495
         fi
503
         fi

+ 4
- 3
src/freedombone-image-customise 查看文件

1065
     rm $rootdir/root/sysctl.conf
1065
     rm $rootdir/root/sysctl.conf
1066
 
1066
 
1067
     # all the packages
1067
     # all the packages
1068
-    chroot "$rootdir" apt-get -yq install cryptsetup libgfshare-bin obnam sshpass wget avahi-daemon
1069
-    chroot "$rootdir" apt-get -yq install avahi-utils avahi-discover connect-proxy openssh-server
1068
+    chroot "$rootdir" apt-get -yq install cryptsetup libgfshare-bin duplicity sshpass wget
1069
+    chroot "$rootdir" apt-get -yq install avahi-daemon avahi-utils avahi-discover
1070
+    chroot "$rootdir" apt-get -yq install connect-proxy openssh-server
1070
     chroot "$rootdir" apt-get -yq install sudo git dialog build-essential avahi-daemon avahi-utils
1071
     chroot "$rootdir" apt-get -yq install sudo git dialog build-essential avahi-daemon avahi-utils
1071
     chroot "$rootdir" apt-get -yq install avahi-discover avahi-autoipd iptables dnsutils net-tools
1072
     chroot "$rootdir" apt-get -yq install avahi-discover avahi-autoipd iptables dnsutils net-tools
1072
     chroot "$rootdir" apt-get -yq install network-manager iputils-ping libnss-mdns libnss-myhostname
1073
     chroot "$rootdir" apt-get -yq install network-manager iputils-ping libnss-mdns libnss-myhostname
1166
     chroot "$rootdir" apt-get -yq install dovecot-imapd
1167
     chroot "$rootdir" apt-get -yq install dovecot-imapd
1167
 
1168
 
1168
     #backup
1169
     #backup
1169
-    chroot "$rootdir" apt-get -yq install obnam gnupg
1170
+    chroot "$rootdir" apt-get -yq install duplicity gnupg
1170
 
1171
 
1171
     # monkeysphere
1172
     # monkeysphere
1172
     #chroot "$rootdir" apt-get -yq install monkeysphere msva-perl
1173
     #chroot "$rootdir" apt-get -yq install monkeysphere msva-perl

+ 132
- 36
src/freedombone-restore-local 查看文件

123
         temp_restore_dir=/root/tempblocklist
123
         temp_restore_dir=/root/tempblocklist
124
         restore_directory_from_usb $temp_restore_dir blocklist
124
         restore_directory_from_usb $temp_restore_dir blocklist
125
 
125
 
126
-        if [ -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg ]; then
126
+        if [ -d $temp_restore_dir/root/tempbackupblocklist ]; then
127
             cp -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
127
             cp -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
128
+        else
129
+            cp -f $temp_restore_dir/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
128
         fi
130
         fi
129
 
131
 
130
         rm -rf $temp_restore_dir
132
         rm -rf $temp_restore_dir
146
         temp_restore_dir=/root/tempconfigfiles
148
         temp_restore_dir=/root/tempconfigfiles
147
         restore_directory_from_usb $temp_restore_dir configfiles
149
         restore_directory_from_usb $temp_restore_dir configfiles
148
 
150
 
149
-        if [ -f $temp_restore_dir/root/.nostore ]; then
150
-            if [ ! -f /root/.nostore ]; then
151
-                touch /root/.nostore
151
+        if [ -d $temp_restore_dir/root ]; then
152
+            if [ -f $temp_restore_dir/root/.nostore ]; then
153
+                if [ ! -f /root/.nostore ]; then
154
+                    touch /root/.nostore
155
+                fi
156
+            else
157
+                if [ -f /root/.nostore ]; then
158
+                    rm /root/.nostore
159
+                fi
152
             fi
160
             fi
153
         else
161
         else
154
-            if [ -f /root/.nostore ]; then
155
-                rm /root/.nostore
162
+            if [ -f $temp_restore_dir/.nostore ]; then
163
+                if [ ! -f /root/.nostore ]; then
164
+                    touch /root/.nostore
165
+                fi
166
+            else
167
+                if [ -f /root/.nostore ]; then
168
+                    rm /root/.nostore
169
+                fi
156
             fi
170
             fi
157
         fi
171
         fi
158
 
172
 
196
         fi
210
         fi
197
 
211
 
198
         # restore nginx password hashes
212
         # restore nginx password hashes
199
-        if [ -f $temp_restore_dir/root/htpasswd ]; then
200
-            cp -f $temp_restore_dir/root/htpasswd /etc/nginx/.htpasswd
213
+        if [ -d $temp_restore_dir/root ]; then
214
+            if [ -f $temp_restore_dir/root/htpasswd ]; then
215
+                cp -f $temp_restore_dir/root/htpasswd /etc/nginx/.htpasswd
216
+            fi
217
+        else
218
+            if [ -f $temp_restore_dir/htpasswd ]; then
219
+                cp -f $temp_restore_dir/htpasswd /etc/nginx/.htpasswd
220
+            fi
201
         fi
221
         fi
202
 
222
 
203
         rm -rf $temp_restore_dir
223
         rm -rf $temp_restore_dir
238
         db_pass=$(cat /root/.mariadboriginal)
258
         db_pass=$(cat /root/.mariadboriginal)
239
         if [ ${#db_pass} -gt 0 ]; then
259
         if [ ${#db_pass} -gt 0 ]; then
240
             echo $"Restore the MariaDB user table"
260
             echo $"Restore the MariaDB user table"
241
-            mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
261
+            if [ -d ${temp_restore_dir}${temp_restore_dir} ]; then
262
+                mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
263
+            else
264
+                mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}/mysql.sql)
265
+            fi
242
             if [ ! "$?" = "0" ]; then
266
             if [ ! "$?" = "0" ]; then
243
                 echo $"Try again using the password obtained from backup"
267
                 echo $"Try again using the password obtained from backup"
244
                 db_pass=$(${PROJECT_NAME}-pass -u root -a mariadb)
268
                 db_pass=$(${PROJECT_NAME}-pass -u root -a mariadb)
245
-                mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
269
+                if [ -d ${temp_restore_dir}${temp_restore_dir} ]; then
270
+                    mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
271
+                else
272
+                    mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}/mysql.sql)
273
+                fi
246
             fi
274
             fi
247
             if [ ! "$?" = "0" ]; then
275
             if [ ! "$?" = "0" ]; then
248
                 echo "$mysqlsuccess"
276
                 echo "$mysqlsuccess"
269
     fi
297
     fi
270
     if [ -d $USB_MOUNT/backup/letsencrypt ]; then
298
     if [ -d $USB_MOUNT/backup/letsencrypt ]; then
271
         echo $"Restoring Lets Encrypt settings"
299
         echo $"Restoring Lets Encrypt settings"
272
-        restore_directory_from_usb / letsencrypt
300
+        #restore_directory_from_usb / letsencrypt
301
+        restore_directory_from_usb /etc/letsencrypt letsencrypt
273
         chgrp -R ssl-cert /etc/letsencrypt
302
         chgrp -R ssl-cert /etc/letsencrypt
274
         chmod -R g=rX /etc/letsencrypt
303
         chmod -R g=rX /etc/letsencrypt
275
     fi
304
     fi
284
     if [ -d $USB_MOUNT/backup/passwordstore ]; then
313
     if [ -d $USB_MOUNT/backup/passwordstore ]; then
285
         store_original_mariadb_password
314
         store_original_mariadb_password
286
         echo $"Restoring password store"
315
         echo $"Restoring password store"
287
-        restore_directory_from_usb / passwordstore
316
+        #restore_directory_from_usb / passwordstore
317
+        restore_directory_from_usb /root/.passwords passwordstore
288
     fi
318
     fi
289
 }
319
 }
290
 
320
 
296
     fi
326
     fi
297
     if [ -d $USB_MOUNT/backup/tor ]; then
327
     if [ -d $USB_MOUNT/backup/tor ]; then
298
         echo $"Restoring Tor settings"
328
         echo $"Restoring Tor settings"
299
-        restore_directory_from_usb / tor
329
+        #restore_directory_from_usb / tor
330
+        restore_directory_from_usb /var/lib/tor tor
300
     fi
331
     fi
301
 }
332
 }
302
 
333
 
316
                 echo $"Restoring Mutt settings for $USERNAME"
347
                 echo $"Restoring Mutt settings for $USERNAME"
317
                 temp_restore_dir=/root/tempmutt
348
                 temp_restore_dir=/root/tempmutt
318
                 restore_directory_from_usb $temp_restore_dir mutt/$USERNAME
349
                 restore_directory_from_usb $temp_restore_dir mutt/$USERNAME
319
-                if [ -f $temp_restore_dir/home/$USERNAME/tempbackup/.muttrc ]; then
320
-                    cp -f $temp_restore_dir/home/$USERNAME/tempbackup/.muttrc /home/$USERNAME/.muttrc
321
-                    sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc
322
-                    sed -i '/set sidebar_sort/d' /home/$USERNAME/.muttrc
323
-                fi
324
-                if [ -f $temp_restore_dir/home/$USERNAME/tempbackup/Muttrc ]; then
325
-                    cp -f $temp_restore_dir/home/$USERNAME/tempbackup/Muttrc /etc/Muttrc
326
-                    sed -i '/set sidebar_delim/d' /etc/Muttrc
327
-                    sed -i '/set sidebar_sort/d' /etc/Muttrc
350
+                if [ -d $temp_restore_dir/home/$USERNAME/tempbackup ]; then
351
+                    if [ -f $temp_restore_dir/home/$USERNAME/tempbackup/.muttrc ]; then
352
+                        cp -f $temp_restore_dir/home/$USERNAME/tempbackup/.muttrc /home/$USERNAME/.muttrc
353
+                        sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc
354
+                        sed -i '/set sidebar_sort/d' /home/$USERNAME/.muttrc
355
+                    fi
356
+                    if [ -f $temp_restore_dir/home/$USERNAME/tempbackup/Muttrc ]; then
357
+                        cp -f $temp_restore_dir/home/$USERNAME/tempbackup/Muttrc /etc/Muttrc
358
+                        sed -i '/set sidebar_delim/d' /etc/Muttrc
359
+                        sed -i '/set sidebar_sort/d' /etc/Muttrc
360
+                    fi
361
+                else
362
+                    if [ -f $temp_restore_dir/.muttrc ]; then
363
+                        cp -f $temp_restore_dir/.muttrc /home/$USERNAME/.muttrc
364
+                        sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc
365
+                        sed -i '/set sidebar_sort/d' /home/$USERNAME/.muttrc
366
+                    fi
367
+                    if [ -f $temp_restore_dir/Muttrc ]; then
368
+                        cp -f $temp_restore_dir/Muttrc /etc/Muttrc
369
+                        sed -i '/set sidebar_delim/d' /etc/Muttrc
370
+                        sed -i '/set sidebar_sort/d' /etc/Muttrc
371
+                    fi
328
                 fi
372
                 fi
329
                 if [ ! "$?" = "0" ]; then
373
                 if [ ! "$?" = "0" ]; then
330
                     rm -rf $temp_restore_dir
374
                     rm -rf $temp_restore_dir
353
                 echo $"Restoring gnupg settings for $USERNAME"
397
                 echo $"Restoring gnupg settings for $USERNAME"
354
                 temp_restore_dir=/root/tempgnupg
398
                 temp_restore_dir=/root/tempgnupg
355
                 restore_directory_from_usb $temp_restore_dir gnupg/$USERNAME
399
                 restore_directory_from_usb $temp_restore_dir gnupg/$USERNAME
356
-                cp -r $temp_restore_dir/home/$USERNAME/.gnupg /home/$USERNAME/
400
+                if [ -d $temp_restore_dir/home/$USERNAME/.gnupg ]; then
401
+                    cp -r $temp_restore_dir/home/$USERNAME/.gnupg /home/$USERNAME/
402
+                else
403
+                    cp -r $temp_restore_dir/* /home/$USERNAME/.gnupg/
404
+                fi
357
                 if [ ! "$?" = "0" ]; then
405
                 if [ ! "$?" = "0" ]; then
358
                     rm -rf $temp_restore_dir
406
                     rm -rf $temp_restore_dir
359
                     set_user_permissions
407
                     set_user_permissions
393
                 temp_restore_dir=/root/tempprocmail
441
                 temp_restore_dir=/root/tempprocmail
394
                 restore_directory_from_usb $temp_restore_dir procmail/$USERNAME
442
                 restore_directory_from_usb $temp_restore_dir procmail/$USERNAME
395
                 if [ -d $temp_restore_dir ]; then
443
                 if [ -d $temp_restore_dir ]; then
396
-                    cp -f $temp_restore_dir/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/
444
+                    if [ -d $temp_restore_dir/home/$USERNAME/tempbackup ]; then
445
+                        cp -f $temp_restore_dir/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/
446
+                    else
447
+                        cp -f $temp_restore_dir/.procmailrc /home/$USERNAME/.procmailrc
448
+                    fi
397
                     if [ ! "$?" = "0" ]; then
449
                     if [ ! "$?" = "0" ]; then
398
                         rm -rf $temp_restore_dir
450
                         rm -rf $temp_restore_dir
399
                         set_user_permissions
451
                         set_user_permissions
424
                     echo $"Restoring spamassassin settings for $USERNAME"
476
                     echo $"Restoring spamassassin settings for $USERNAME"
425
                     temp_restore_dir=/root/tempspamassassin
477
                     temp_restore_dir=/root/tempspamassassin
426
                     restore_directory_from_usb $temp_restore_dir spamassassin/$USERNAME
478
                     restore_directory_from_usb $temp_restore_dir spamassassin/$USERNAME
427
-                    cp -rf $temp_restore_dir/home/$USERNAME/.spamassassin /home/$USERNAME/
479
+                    if [ -d $temp_restore_dir/home/$USERNAME ]; then
480
+                        cp -rf $temp_restore_dir/home/$USERNAME/.spamassassin /home/$USERNAME/
481
+                    else
482
+                        cp -rf $temp_restore_dir/* /home/$USERNAME/.spamassassin/
483
+                    fi
428
                     if [ ! "$?" = "0" ]; then
484
                     if [ ! "$?" = "0" ]; then
429
                         rm -rf $temp_restore_dir
485
                         rm -rf $temp_restore_dir
430
                         set_user_permissions
486
                         set_user_permissions
457
 
513
 
458
         temp_restore_dir=/root/tempreadme
514
         temp_restore_dir=/root/tempreadme
459
         restore_directory_from_usb $temp_restore_dir readme
515
         restore_directory_from_usb $temp_restore_dir readme
460
-        cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/README /home/$ADMIN_USERNAME/
516
+        if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
517
+            cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/README /home/$ADMIN_USERNAME/
518
+        else
519
+            cp -f $temp_restore_dir/README /home/$ADMIN_USERNAME/README
520
+        fi
461
         if [ ! "$?" = "0" ]; then
521
         if [ ! "$?" = "0" ]; then
462
             rm -rf $temp_restore_dir
522
             rm -rf $temp_restore_dir
463
             set_user_permissions
523
             set_user_permissions
484
                 echo $"Restoring ssh keys for $USERNAME"
544
                 echo $"Restoring ssh keys for $USERNAME"
485
                 temp_restore_dir=/root/tempssh
545
                 temp_restore_dir=/root/tempssh
486
                 restore_directory_from_usb $temp_restore_dir ssh/$USERNAME
546
                 restore_directory_from_usb $temp_restore_dir ssh/$USERNAME
487
-                cp -r $temp_restore_dir/home/$USERNAME/.ssh /home/$USERNAME/
547
+                if [ -d $temp_restore_dir/home/$USERNAME/.ssh ]; then
548
+                    cp -r $temp_restore_dir/home/$USERNAME/.ssh /home/$USERNAME/
549
+                else
550
+                    cp -r $temp_restore_dir/* /home/$USERNAME/.ssh/
551
+                fi
488
                 if [ ! "$?" = "0" ]; then
552
                 if [ ! "$?" = "0" ]; then
489
                     rm -rf $temp_restore_dir
553
                     rm -rf $temp_restore_dir
490
                     set_user_permissions
554
                     set_user_permissions
513
                 echo $"Restoring config files for $USERNAME"
577
                 echo $"Restoring config files for $USERNAME"
514
                 temp_restore_dir=/root/tempconfig
578
                 temp_restore_dir=/root/tempconfig
515
                 restore_directory_from_usb $temp_restore_dir config/$USERNAME
579
                 restore_directory_from_usb $temp_restore_dir config/$USERNAME
516
-                cp -r $temp_restore_dir/home/$USERNAME/.config /home/$USERNAME/
580
+                if [ -d $temp_restore_dir/home/$USERNAME/.config ]; then
581
+                    cp -r $temp_restore_dir/home/$USERNAME/.config /home/$USERNAME/
582
+                else
583
+                    cp -r $temp_restore_dir/* /home/$USERNAME/.config/
584
+                fi
517
                 if [ ! "$?" = "0" ]; then
585
                 if [ ! "$?" = "0" ]; then
518
                     rm -rf $temp_restore_dir
586
                     rm -rf $temp_restore_dir
519
                     set_user_permissions
587
                     set_user_permissions
542
                 echo $"Restoring monkeysphere ids for $USERNAME"
610
                 echo $"Restoring monkeysphere ids for $USERNAME"
543
                 temp_restore_dir=/root/tempmonkeysphere
611
                 temp_restore_dir=/root/tempmonkeysphere
544
                 restore_directory_from_usb $temp_restore_dir monkeysphere/$USERNAME
612
                 restore_directory_from_usb $temp_restore_dir monkeysphere/$USERNAME
545
-                cp -r $temp_restore_dir/home/$USERNAME/.monkeysphere /home/$USERNAME/
613
+                if [ -d $temp_restore_dir/home/$USERNAME/.monkeysphere ]; then
614
+                    cp -r $temp_restore_dir/home/$USERNAME/.monkeysphere /home/$USERNAME/
615
+                else
616
+                    cp -r $temp_restore_dir/* /home/$USERNAME/.monkeysphere
617
+                fi
546
                 if [ ! "$?" = "0" ]; then
618
                 if [ ! "$?" = "0" ]; then
547
                     rm -rf $temp_restore_dir
619
                     rm -rf $temp_restore_dir
548
                     set_user_permissions
620
                     set_user_permissions
579
                 echo $"Restoring fin files for $USERNAME"
651
                 echo $"Restoring fin files for $USERNAME"
580
                 temp_restore_dir=/root/tempfin
652
                 temp_restore_dir=/root/tempfin
581
                 restore_directory_from_usb $temp_restore_dir fin/$USERNAME
653
                 restore_directory_from_usb $temp_restore_dir fin/$USERNAME
582
-                cp -r $temp_restore_dir/home/$USERNAME/.fin /home/$USERNAME/
654
+                if [ -d $temp_restore_dir/home/$USERNAME/.fin ]; then
655
+                    cp -r $temp_restore_dir/home/$USERNAME/.fin /home/$USERNAME/
656
+                else
657
+                    cp -r $temp_restore_dir/* /home/$USERNAME/.fin/
658
+                fi
583
                 if [ ! "$?" = "0" ]; then
659
                 if [ ! "$?" = "0" ]; then
584
                     rm -rf $temp_restore_dir
660
                     rm -rf $temp_restore_dir
585
                     set_user_permissions
661
                     set_user_permissions
608
                 echo $"Restoring local files for $USERNAME"
684
                 echo $"Restoring local files for $USERNAME"
609
                 temp_restore_dir=/root/templocal
685
                 temp_restore_dir=/root/templocal
610
                 restore_directory_from_usb $temp_restore_dir local/$USERNAME
686
                 restore_directory_from_usb $temp_restore_dir local/$USERNAME
611
-                cp -r $temp_restore_dir/home/$USERNAME/.local /home/$USERNAME/
687
+                if [ -d $temp_restore_dir/home/$USERNAME/.local ]; then
688
+                    cp -r $temp_restore_dir/home/$USERNAME/.local /home/$USERNAME/
689
+                else
690
+                    cp -r $temp_restore_dir/* /home/$USERNAME/.local/
691
+                fi
612
                 if [ ! "$?" = "0" ]; then
692
                 if [ ! "$?" = "0" ]; then
613
                     rm -rf $temp_restore_dir
693
                     rm -rf $temp_restore_dir
614
                     set_user_permissions
694
                     set_user_permissions
631
         echo $"Restoring certificates"
711
         echo $"Restoring certificates"
632
         mkdir /root/tempssl
712
         mkdir /root/tempssl
633
         restore_directory_from_usb /root/tempssl ssl
713
         restore_directory_from_usb /root/tempssl ssl
634
-        cp -r /root/tempssl/etc/ssl/* /etc/ssl
714
+        if [ -d /root/tempssl/etc/ssl ]; then
715
+            cp -r /root/tempssl/etc/ssl/* /etc/ssl
716
+        else
717
+            cp -r /root/tempssl/* /etc/ssl/
718
+        fi
635
         if [ ! "$?" = "0" ]; then
719
         if [ ! "$?" = "0" ]; then
636
             set_user_permissions
720
             set_user_permissions
637
             backup_unmount_drive
721
             backup_unmount_drive
686
                     if [ -d /home/$USERNAME/personal ]; then
770
                     if [ -d /home/$USERNAME/personal ]; then
687
                         rm -rf /home/$USERNAME/personal
771
                         rm -rf /home/$USERNAME/personal
688
                     fi
772
                     fi
689
-                    mv $temp_restore_dir/home/$USERNAME/personal /home/$USERNAME
773
+                    if [ -d $temp_restore_dir/home/$USERNAME/personal ]; then
774
+                        mv $temp_restore_dir/home/$USERNAME/personal /home/$USERNAME
775
+                    else
776
+                        cp -r $temp_restore_dir/* /home/$USERNAME/personal/
777
+                    fi
690
                     if [ ! "$?" = "0" ]; then
778
                     if [ ! "$?" = "0" ]; then
691
                         set_user_permissions
779
                         set_user_permissions
692
                         backup_unmount_drive
780
                         backup_unmount_drive
709
         echo $"Restoring public mailing list"
797
         echo $"Restoring public mailing list"
710
         temp_restore_dir=/root/tempmailinglist
798
         temp_restore_dir=/root/tempmailinglist
711
         restore_directory_from_usb $temp_restore_dir mailinglist
799
         restore_directory_from_usb $temp_restore_dir mailinglist
712
-        cp -r $temp_restore_dir/root/spool/mlmmj/* /var/spool/mlmmj
800
+        if [ -d $temp_restore_dir/root/spool/mlmmj ]; then
801
+            cp -r $temp_restore_dir/root/spool/mlmmj/* /var/spool/mlmmj
802
+        else
803
+            cp -r $temp_restore_dir/* /var/spool/mlmmj/
804
+        fi
713
         if [ ! "$?" = "0" ]; then
805
         if [ ! "$?" = "0" ]; then
714
             set_user_permissions
806
             set_user_permissions
715
             backup_unmount_drive
807
             backup_unmount_drive
738
                 if [ ! -d /home/$USERNAME/Maildir ]; then
830
                 if [ ! -d /home/$USERNAME/Maildir ]; then
739
                     mkdir /home/$USERNAME/Maildir
831
                     mkdir /home/$USERNAME/Maildir
740
                 fi
832
                 fi
741
-                tar -xzvf $temp_restore_dir/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
833
+                if [ -d $temp_restore_dir/root/tempbackupemail/$USERNAME ]; then
834
+                    tar -xzvf $temp_restore_dir/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
835
+                else
836
+                    tar -xzvf $temp_restore_dir/maildir.tar.gz -C /
837
+                fi
742
                 if [ ! "$?" = "0" ]; then
838
                 if [ ! "$?" = "0" ]; then
743
                     set_user_permissions
839
                     set_user_permissions
744
                     backup_unmount_drive
840
                     backup_unmount_drive
745
-                    exit 927
841
+                    exit 9276382
746
                 fi
842
                 fi
747
                 rm -rf $temp_restore_dir
843
                 rm -rf $temp_restore_dir
748
             fi
844
             fi

+ 123
- 37
src/freedombone-restore-remote 查看文件

113
         echo $"Restoring blocklist"
113
         echo $"Restoring blocklist"
114
         temp_restore_dir=/root/tempblocklist
114
         temp_restore_dir=/root/tempblocklist
115
         restore_directory_from_friend $temp_restore_dir blocklist
115
         restore_directory_from_friend $temp_restore_dir blocklist
116
-        restore_directory_from_usb $temp_restore_dir blocklist
117
 
116
 
118
-        if [ -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg ]; then
117
+        if [ -d $temp_restore_dir/root/tempbackupblocklist ]; then
119
             cp -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
118
             cp -f $temp_restore_dir/root/tempbackupblocklist/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
119
+        else
120
+            cp -f $temp_restore_dir/${PROJECT_NAME}-firewall-domains.cfg /root/${PROJECT_NAME}-firewall-domains.cfg
120
         fi
121
         fi
121
 
122
 
122
         rm -rf $temp_restore_dir
123
         rm -rf $temp_restore_dir
136
         temp_restore_dir=/root/tempconfigfiles
137
         temp_restore_dir=/root/tempconfigfiles
137
         restore_directory_from_friend $temp_restore_dir configfiles
138
         restore_directory_from_friend $temp_restore_dir configfiles
138
 
139
 
139
-        if [ -f $temp_restore_dir/root/.nostore ]; then
140
-            if [ ! -f /root/.nostore ]; then
141
-                touch /root/.nostore
140
+        if [ -d $temp_restore_dir/root ]; then
141
+            if [ -f $temp_restore_dir/root/.nostore ]; then
142
+                if [ ! -f /root/.nostore ]; then
143
+                    touch /root/.nostore
144
+                fi
145
+            else
146
+                if [ -f /root/.nostore ]; then
147
+                    rm /root/.nostore
148
+                fi
142
             fi
149
             fi
143
         else
150
         else
144
-            if [ -f /root/.nostore ]; then
145
-                rm /root/.nostore
151
+            if [ -f $temp_restore_dir/.nostore ]; then
152
+                if [ ! -f /root/.nostore ]; then
153
+                    touch /root/.nostore
154
+                fi
155
+            else
156
+                if [ -f /root/.nostore ]; then
157
+                    rm /root/.nostore
158
+                fi
146
             fi
159
             fi
147
         fi
160
         fi
148
 
161
 
214
         db_pass=$(cat /root/.mariadboriginal)
227
         db_pass=$(cat /root/.mariadboriginal)
215
         if [ ${#db_pass} -gt 0 ]; then
228
         if [ ${#db_pass} -gt 0 ]; then
216
             echo $"Restore the MariaDB user table"
229
             echo $"Restore the MariaDB user table"
217
-            mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
230
+            if [ -d ${temp_restore_dir}${temp_restore_dir} ]; then
231
+                mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
232
+            else
233
+                mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}/mysql.sql)
234
+            fi
218
             if [ ! "$?" = "0" ]; then
235
             if [ ! "$?" = "0" ]; then
219
                 echo $"Try again using the password obtained from backup"
236
                 echo $"Try again using the password obtained from backup"
220
                 db_pass=$(${PROJECT_NAME}-pass -u root -a mariadb)
237
                 db_pass=$(${PROJECT_NAME}-pass -u root -a mariadb)
221
-                mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
238
+                if [ -d ${temp_restore_dir}${temp_restore_dir} ]; then
239
+                    mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}${temp_restore_dir}/mysql.sql)
240
+                else
241
+                    mysqlsuccess=$(mysql -u root --password="$db_pass" mysql -o < ${temp_restore_dir}/mysql.sql)
242
+                fi
222
             fi
243
             fi
223
             if [ ! "$?" = "0" ]; then
244
             if [ ! "$?" = "0" ]; then
224
                 echo "$mysqlsuccess"
245
                 echo "$mysqlsuccess"
242
     fi
263
     fi
243
     if [ -d $SERVER_DIRECTORY/backup/letsencrypt ]; then
264
     if [ -d $SERVER_DIRECTORY/backup/letsencrypt ]; then
244
         echo $"Restoring Lets Encrypt settings"
265
         echo $"Restoring Lets Encrypt settings"
245
-        restore_directory_from_friend / letsencrypt
266
+        restore_directory_from_friend /etc/letsencrypt letsencrypt
246
     fi
267
     fi
247
 }
268
 }
248
 
269
 
255
     if [ -d $SERVER_DIRECTORY/backup/passwordstore ]; then
276
     if [ -d $SERVER_DIRECTORY/backup/passwordstore ]; then
256
         store_original_mariadb_password
277
         store_original_mariadb_password
257
         echo $"Restoring password store"
278
         echo $"Restoring password store"
258
-        restore_directory_from_friend / passwordstore
279
+        restore_directory_from_friend /root/.passwords passwordstore
259
     fi
280
     fi
260
 }
281
 }
261
 
282
 
267
     fi
288
     fi
268
     if [ -d $SERVER_DIRECTORY/backup/tor ]; then
289
     if [ -d $SERVER_DIRECTORY/backup/tor ]; then
269
         echo $"Restoring Tor settings"
290
         echo $"Restoring Tor settings"
270
-        restore_directory_from_friend / tor
291
+        restore_directory_from_friend /var/lib/tor tor
271
     fi
292
     fi
272
 }
293
 }
273
 
294
 
287
                 echo $"Restoring Mutt settings for $USERNAME"
308
                 echo $"Restoring Mutt settings for $USERNAME"
288
                 temp_restore_dir=/root/tempmutt
309
                 temp_restore_dir=/root/tempmutt
289
                 restore_directory_from_friend ${temp_restore_dir} mutt/$USERNAME
310
                 restore_directory_from_friend ${temp_restore_dir} mutt/$USERNAME
290
-                if [ -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.muttrc ]; then
291
-                    cp -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.muttrc /home/$USERNAME/.muttrc
292
-                    sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc
293
-                    sed -i '/set sidebar_sort/d' /home/$USERNAME/.muttrc
294
-                fi
295
-                if [ -f ${temp_restore_dir}/home/$USERNAME/tempbackup/Muttrc ]; then
296
-                    cp -f ${temp_restore_dir}/home/$USERNAME/tempbackup/Muttrc /etc/Muttrc
297
-                    sed -i '/set sidebar_delim/d' /etc/Muttrc
298
-                    sed -i '/set sidebar_sort/d' /etc/Muttrc
311
+                if [ -d ${temp_restore_dir}/home/$USERNAME/tempbackup ]; then
312
+                    if [ -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.muttrc ]; then
313
+                        cp -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.muttrc /home/$USERNAME/.muttrc
314
+                        sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc
315
+                        sed -i '/set sidebar_sort/d' /home/$USERNAME/.muttrc
316
+                    fi
317
+                    if [ -f ${temp_restore_dir}/home/$USERNAME/tempbackup/Muttrc ]; then
318
+                        cp -f ${temp_restore_dir}/home/$USERNAME/tempbackup/Muttrc /etc/Muttrc
319
+                        sed -i '/set sidebar_delim/d' /etc/Muttrc
320
+                        sed -i '/set sidebar_sort/d' /etc/Muttrc
321
+                    fi
322
+                else
323
+                    if [ -f ${temp_restore_dir}/.muttrc ]; then
324
+                        cp -f ${temp_restore_dir}/.muttrc /home/$USERNAME/.muttrc
325
+                        sed -i '/set sidebar_delim/d' /home/$USERNAME/.muttrc
326
+                        sed -i '/set sidebar_sort/d' /home/$USERNAME/.muttrc
327
+                    fi
328
+                    if [ -f ${temp_restore_dir}/Muttrc ]; then
329
+                        cp -f ${temp_restore_dir}/Muttrc /etc/Muttrc
330
+                        sed -i '/set sidebar_delim/d' /etc/Muttrc
331
+                        sed -i '/set sidebar_sort/d' /etc/Muttrc
332
+                    fi
299
                 fi
333
                 fi
300
                 if [ ! "$?" = "0" ]; then
334
                 if [ ! "$?" = "0" ]; then
301
                     rm -rf ${temp_restore_dir}
335
                     rm -rf ${temp_restore_dir}
322
                 echo $"Restoring gnupg settings for $USERNAME"
356
                 echo $"Restoring gnupg settings for $USERNAME"
323
                 temp_restore_dir=/root/tempgnupg
357
                 temp_restore_dir=/root/tempgnupg
324
                 restore_directory_from_friend ${temp_restore_dir} gnupg/$USERNAME
358
                 restore_directory_from_friend ${temp_restore_dir} gnupg/$USERNAME
325
-                cp -r ${temp_restore_dir}/home/$USERNAME/.gnupg /home/$USERNAME/
359
+                if [ -d ${temp_restore_dir}/home/$USERNAME/.gnupg ]; then
360
+                    cp -r ${temp_restore_dir}/home/$USERNAME/.gnupg /home/$USERNAME/
361
+                else
362
+                    cp -r ${temp_restore_dir}/* /home/$USERNAME/.gnupg/
363
+                fi
326
                 if [ ! "$?" = "0" ]; then
364
                 if [ ! "$?" = "0" ]; then
327
                     rm -rf ${temp_restore_dir}
365
                     rm -rf ${temp_restore_dir}
328
                     exit 276
366
                     exit 276
356
                 echo $"Restoring procmail settings for $USERNAME"
394
                 echo $"Restoring procmail settings for $USERNAME"
357
                 temp_restore_dir=/root/tempprocmail
395
                 temp_restore_dir=/root/tempprocmail
358
                 restore_directory_from_friend ${temp_restore_dir} procmail/$USERNAME
396
                 restore_directory_from_friend ${temp_restore_dir} procmail/$USERNAME
359
-                cp -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/
397
+                if [ -d ${temp_restore_dir}/home/$USERNAME/tempbackup ]; then
398
+                    cp -f ${temp_restore_dir}/home/$USERNAME/tempbackup/.procmailrc /home/$USERNAME/
399
+                else
400
+                    cp -f ${temp_restore_dir}/.procmailrc /home/$USERNAME/.procmailrc
401
+                fi
360
                 if [ ! "$?" = "0" ]; then
402
                 if [ ! "$?" = "0" ]; then
361
                     rm -rf ${temp_restore_dir}
403
                     rm -rf ${temp_restore_dir}
362
                     exit 276
404
                     exit 276
383
                 echo $"Restoring spamassassin settings for $USERNAME"
425
                 echo $"Restoring spamassassin settings for $USERNAME"
384
                 temp_restore_dir=/root/tempspamassassin
426
                 temp_restore_dir=/root/tempspamassassin
385
                 restore_directory_from_friend $temp_restore_dir spamassassin/$USERNAME
427
                 restore_directory_from_friend $temp_restore_dir spamassassin/$USERNAME
386
-                cp -rf $temp_restore_dir/home/$USERNAME/.spamassassin /home/$USERNAME/
428
+                if [ -d $temp_restore_dir/home/$USERNAME ]; then
429
+                    cp -rf $temp_restore_dir/home/$USERNAME/.spamassassin /home/$USERNAME/
430
+                else
431
+                    cp -rf $temp_restore_dir/* /home/$USERNAME/.spamassassin/
432
+                fi
387
                 if [ ! "$?" = "0" ]; then
433
                 if [ ! "$?" = "0" ]; then
388
                     rm -rf $temp_restore_dir
434
                     rm -rf $temp_restore_dir
389
                     exit 276
435
                     exit 276
404
         echo $"Restoring README"
450
         echo $"Restoring README"
405
         temp_restore_dir=/root/tempreadme
451
         temp_restore_dir=/root/tempreadme
406
         restore_directory_from_friend $temp_restore_dir readme
452
         restore_directory_from_friend $temp_restore_dir readme
407
-        cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/README /home/$ADMIN_USERNAME/
453
+        if [ -d $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup ]; then
454
+            cp -f $temp_restore_dir/home/$ADMIN_USERNAME/tempbackup/README /home/$ADMIN_USERNAME/
455
+        else
456
+            cp -f $temp_restore_dir/README /home/$ADMIN_USERNAME/README
457
+        fi
408
         if [ ! "$?" = "0" ]; then
458
         if [ ! "$?" = "0" ]; then
409
             rm -rf $temp_restore_dir
459
             rm -rf $temp_restore_dir
410
             exit 276
460
             exit 276
429
                 echo $"Restoring ssh keys for $USERNAME"
479
                 echo $"Restoring ssh keys for $USERNAME"
430
                 temp_restore_dir=/root/tempssh
480
                 temp_restore_dir=/root/tempssh
431
                 restore_directory_from_friend $temp_restore_dir ssh/$USERNAME
481
                 restore_directory_from_friend $temp_restore_dir ssh/$USERNAME
432
-                cp -r $temp_restore_dir/home/$USERNAME/.ssh /home/$USERNAME/
482
+                if [ -d $temp_restore_dir/home/$USERNAME/.ssh ]; then
483
+                    cp -r $temp_restore_dir/home/$USERNAME/.ssh /home/$USERNAME/
484
+                else
485
+                    cp -r $temp_restore_dir/* /home/$USERNAME/.ssh/
486
+                fi
433
                 if [ ! "$?" = "0" ]; then
487
                 if [ ! "$?" = "0" ]; then
434
                     rm -rf $temp_restore_dir
488
                     rm -rf $temp_restore_dir
435
                     exit 664
489
                     exit 664
456
                 echo $"Restoring config files for $USERNAME"
510
                 echo $"Restoring config files for $USERNAME"
457
                 temp_restore_dir=/root/tempconfig
511
                 temp_restore_dir=/root/tempconfig
458
                 restore_directory_from_friend $temp_restore_dir config/$USERNAME
512
                 restore_directory_from_friend $temp_restore_dir config/$USERNAME
459
-                cp -r $temp_restore_dir/home/$USERNAME/.config /home/$USERNAME/
513
+                if [ -d $temp_restore_dir/home/$USERNAME ]; then
514
+                    cp -r $temp_restore_dir/home/$USERNAME/.config /home/$USERNAME/
515
+                else
516
+                    cp -r $temp_restore_dir/* /home/$USERNAME/.config/
517
+                fi
460
                 if [ ! "$?" = "0" ]; then
518
                 if [ ! "$?" = "0" ]; then
461
                     rm -rf $temp_restore_dir
519
                     rm -rf $temp_restore_dir
462
                     exit 664
520
                     exit 664
483
                 echo $"Restoring monkeysphere ids for $USERNAME"
541
                 echo $"Restoring monkeysphere ids for $USERNAME"
484
                 temp_restore_dir=/root/tempmonkeysphere
542
                 temp_restore_dir=/root/tempmonkeysphere
485
                 restore_directory_from_friend $temp_restore_dir monkeysphere/$USERNAME
543
                 restore_directory_from_friend $temp_restore_dir monkeysphere/$USERNAME
486
-                cp -r $temp_restore_dir/home/$USERNAME/.monkeysphere /home/$USERNAME/
544
+                if [ -d $temp_restore_dir/home/$USERNAME/.monkeysphere ]; then
545
+                    cp -r $temp_restore_dir/home/$USERNAME/.monkeysphere /home/$USERNAME/
546
+                else
547
+                    cp -r $temp_restore_dir/* /home/$USERNAME/.monkeysphere/
548
+                fi
487
                 if [ ! "$?" = "0" ]; then
549
                 if [ ! "$?" = "0" ]; then
488
                     rm -rf $temp_restore_dir
550
                     rm -rf $temp_restore_dir
489
                     exit 664
551
                     exit 664
518
                 echo $"Restoring fin files for $USERNAME"
580
                 echo $"Restoring fin files for $USERNAME"
519
                 temp_restore_dir=/root/tempfin
581
                 temp_restore_dir=/root/tempfin
520
                 restore_directory_from_friend $temp_restore_dir fin/$USERNAME
582
                 restore_directory_from_friend $temp_restore_dir fin/$USERNAME
521
-                cp -r $temp_restore_dir/home/$USERNAME/.fin /home/$USERNAME/
583
+                if [ -d $temp_restore_dir/home/$USERNAME/.fin ]; then
584
+                    cp -r $temp_restore_dir/home/$USERNAME/.fin /home/$USERNAME/
585
+                else
586
+                    cp -r $temp_restore_dir/* /home/$USERNAME/.fin/
587
+                fi
522
                 if [ ! "$?" = "0" ]; then
588
                 if [ ! "$?" = "0" ]; then
523
                     rm -rf $temp_restore_dir
589
                     rm -rf $temp_restore_dir
524
                     exit 664
590
                     exit 664
545
                 echo $"Restoring local files for $USERNAME"
611
                 echo $"Restoring local files for $USERNAME"
546
                 temp_restore_dir=/root/templocal
612
                 temp_restore_dir=/root/templocal
547
                 restore_directory_from_friend $temp_restore_dir local/$USERNAME
613
                 restore_directory_from_friend $temp_restore_dir local/$USERNAME
548
-                cp -r $temp_restore_dir/home/$USERNAME/.local /home/$USERNAME/
614
+                if [ -d $temp_restore_dir/home/$USERNAME/.local ]; then
615
+                    cp -r $temp_restore_dir/home/$USERNAME/.local /home/$USERNAME/
616
+                else
617
+                    cp -r $temp_restore_dir/* /home/$USERNAME/.local/
618
+                fi
549
                 if [ ! "$?" = "0" ]; then
619
                 if [ ! "$?" = "0" ]; then
550
                     rm -rf $temp_restore_dir
620
                     rm -rf $temp_restore_dir
551
                     exit 664
621
                     exit 664
565
     if [ -d $SERVER_DIRECTORY/backup/ssl ]; then
635
     if [ -d $SERVER_DIRECTORY/backup/ssl ]; then
566
         echo $"Restoring certificates"
636
         echo $"Restoring certificates"
567
         restore_directory_from_friend /root/tempssl ssl
637
         restore_directory_from_friend /root/tempssl ssl
568
-        cp -r /root/tempssl/etc/ssl/* /etc/ssl
638
+        if [ -d /root/tempssl/etc/ssl ]; then
639
+            cp -r /root/tempssl/etc/ssl/* /etc/ssl
640
+        else
641
+            cp -r /root/tempssl/* /etc/ssl/
642
+        fi
569
         if [ ! "$?" = "0" ]; then
643
         if [ ! "$?" = "0" ]; then
570
             exit 276
644
             exit 276
571
         fi
645
         fi
614
                 echo $"Restoring personal settings for $USERNAME"
688
                 echo $"Restoring personal settings for $USERNAME"
615
                 temp_restore_dir=/root/temppersonal
689
                 temp_restore_dir=/root/temppersonal
616
                 restore_directory_from_friend $temp_restore_dir personal/$USERNAME
690
                 restore_directory_from_friend $temp_restore_dir personal/$USERNAME
617
-                if [ -d /home/$USERNAME/personal ]; then
618
-                    rm -rf /home/$USERNAME/personal
691
+                if [ -d $temp_restore_dir/home/$USERNAME/personal ]; then
692
+                    if [ -d /home/$USERNAME/personal ]; then
693
+                        rm -rf /home/$USERNAME/personal
694
+                    fi
695
+                    mv $temp_restore_dir/home/$USERNAME/personal /home/$USERNAME
696
+                else
697
+                    cp -r $temp_restore_dir/* /home/$USERNAME/personal/
619
                 fi
698
                 fi
620
-                mv $temp_restore_dir/home/$USERNAME/personal /home/$USERNAME
621
                 if [ ! "$?" = "0" ]; then
699
                 if [ ! "$?" = "0" ]; then
622
-                    exit 184
700
+                    exit 18437643
623
                 fi
701
                 fi
624
                 rm -rf $temp_restore_dir
702
                 rm -rf $temp_restore_dir
625
             fi
703
             fi
637
         echo $"Restoring public mailing list"
715
         echo $"Restoring public mailing list"
638
         temp_restore_dir=/root/tempmailinglist
716
         temp_restore_dir=/root/tempmailinglist
639
         restore_directory_from_friend $temp_restore_dir mailinglist
717
         restore_directory_from_friend $temp_restore_dir mailinglist
640
-        cp -r $temp_restore_dir/root/spool/mlmmj/* /var/spool/mlmmj
718
+        if [ -d $temp_restore_dir/root/spool/mlmmj ]; then
719
+            cp -r $temp_restore_dir/root/spool/mlmmj/* /var/spool/mlmmj
720
+        else
721
+            cp -r $temp_restore_dir/* /var/spool/mlmmj/
722
+        fi
641
         if [ ! "$?" = "0" ]; then
723
         if [ ! "$?" = "0" ]; then
642
             exit 526
724
             exit 526
643
         fi
725
         fi
664
                 if [ ! -d /home/$USERNAME/Maildir ]; then
746
                 if [ ! -d /home/$USERNAME/Maildir ]; then
665
                     mkdir /home/$USERNAME/Maildir
747
                     mkdir /home/$USERNAME/Maildir
666
                 fi
748
                 fi
667
-                tar -xzvf $temp_restore_dir/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
749
+                if [ -d $temp_restore_dir/root/tempbackupemail/$USERNAME ]; then
750
+                    tar -xzvf $temp_restore_dir/root/tempbackupemail/$USERNAME/maildir.tar.gz -C /
751
+                else
752
+                    tar -xzvf $temp_restore_dir/maildir.tar.gz -C /
753
+                fi
668
                 if [ ! "$?" = "0" ]; then
754
                 if [ ! "$?" = "0" ]; then
669
                     exit 927
755
                     exit 927
670
                 fi
756
                 fi

+ 209
- 54
src/freedombone-utils-backup 查看文件

13
 # License
13
 # License
14
 # =======
14
 # =======
15
 #
15
 #
16
-# Copyright (C) 2014-2016 Bob Mottram <bob@freedombone.net>
16
+# Copyright (C) 2014-2017 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
34
 # Dummy password used for the backup key
34
 # Dummy password used for the backup key
35
 BACKUP_DUMMY_PASSWORD='backup'
35
 BACKUP_DUMMY_PASSWORD='backup'
36
 
36
 
37
+BACKUP_TEMP_DIRECTORY=/root/.backuptemp
38
+BACKUP_GPG_OPTIONS="--pinentry-mode loopback"
39
+
40
+function create_backups_temp_directory {
41
+    if [ ! -d $BACKUP_TEMP_DIRECTORY ]; then
42
+        mkdir $BACKUP_TEMP_DIRECTORY
43
+    fi
44
+}
45
+
46
+function remove_backups_temp_directory {
47
+    if [ -d $BACKUP_TEMP_DIRECTORY ]; then
48
+        rm -rf $BACKUP_TEMP_DIRECTORY
49
+    fi
50
+}
51
+
37
 function suspend_site {
52
 function suspend_site {
38
     # suspends a given website
53
     # suspends a given website
39
     SUSPENDED_SITE="$1"
54
     SUSPENDED_SITE="$1"
247
     echo "client-name = ${PROJECT_NAME}" >> /etc/obnam.conf
262
     echo "client-name = ${PROJECT_NAME}" >> /etc/obnam.conf
248
 }
263
 }
249
 
264
 
265
+function backup_directory_to_usb_duplicity {
266
+    create_backups_temp_directory
267
+    echo "$BACKUP_DUMMY_PASSWORD" | duplicity full --gpg-options "$BACKUP_GPG_OPTIONS" --tempdir $BACKUP_TEMP_DIRECTORY --encrypt-key $MY_BACKUP_KEY_ID --full-if-older-than 4W --exclude-other-filesystems ${1} file://$USB_MOUNT/backup/${2}
268
+    if [ ! "$?" = "0" ]; then
269
+        umount $USB_MOUNT
270
+        rm -rf $USB_MOUNT
271
+        if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
272
+            shred -zu ${1}/*
273
+            rm -rf ${1}
274
+        fi
275
+        function_check restart_site
276
+        restart_site
277
+        remove_backups_temp_directory
278
+        exit 8352925
279
+    fi
280
+    if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
281
+        echo "$BACKUP_DUMMY_PASSWORD" | duplicity verify --gpg-options "$BACKUP_GPG_OPTIONS" --tempdir $BACKUP_TEMP_DIRECTORY --encrypt-key $MY_BACKUP_KEY_ID --full-if-older-than 4W --exclude-other-filesystems ${1} file://$USB_MOUNT/backup/${2}
282
+        if [ ! "$?" = "0" ]; then
283
+            umount $USB_MOUNT
284
+            rm -rf $USB_MOUNT
285
+            if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
286
+                shred -zu ${1}/*
287
+                rm -rf ${1}
288
+            fi
289
+            function_check restart_site
290
+            restart_site
291
+            remove_backups_temp_directory
292
+            exit 683252
293
+        fi
294
+    fi
295
+    remove_backups_temp_directory
296
+}
297
+
298
+function backup_directory_to_usb_obnam {
299
+    set_obnam_client_name
300
+    echo "$BACKUP_DUMMY_PASSWORD" | obnam force-lock -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
301
+    echo "$BACKUP_DUMMY_PASSWORD" | obnam backup -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
302
+    if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
303
+        echo "$BACKUP_DUMMY_PASSWORD" | obnam verify -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
304
+        if [ ! "$?" = "0" ]; then
305
+            umount $USB_MOUNT
306
+            rm -rf $USB_MOUNT
307
+            if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
308
+                shred -zu ${1}/*
309
+                rm -rf ${1}
310
+            fi
311
+            function_check restart_site
312
+            restart_site
313
+            exit 683252
314
+        fi
315
+    fi
316
+    echo "$BACKUP_DUMMY_PASSWORD" | obnam forget --keep=30d -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID
317
+    if [ ! "$?" = "0" ]; then
318
+        umount $USB_MOUNT
319
+        rm -rf $USB_MOUNT
320
+        if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
321
+            shred -zu ${1}/*
322
+            rm -rf ${1}
323
+        fi
324
+        function_check restart_site
325
+        restart_site
326
+        exit 7
327
+    fi
328
+}
329
+
250
 function backup_directory_to_usb {
330
 function backup_directory_to_usb {
251
     if [ ! -d ${1} ]; then
331
     if [ ! -d ${1} ]; then
252
         echo $"WARNING: directory does not exist: ${1}"
332
         echo $"WARNING: directory does not exist: ${1}"
263
         if [ ! -d $USB_MOUNT/backup/${2} ]; then
343
         if [ ! -d $USB_MOUNT/backup/${2} ]; then
264
             mkdir -p $USB_MOUNT/backup/${2}
344
             mkdir -p $USB_MOUNT/backup/${2}
265
         fi
345
         fi
266
-        set_obnam_client_name
267
-        echo "$BACKUP_DUMMY_PASSWORD" | obnam force-lock -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
268
-        echo "$BACKUP_DUMMY_PASSWORD" | obnam backup -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
269
-        if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
270
-            echo "$BACKUP_DUMMY_PASSWORD" | obnam verify -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID ${1}
271
-            if [ ! "$?" = "0" ]; then
272
-                umount $USB_MOUNT
273
-                rm -rf $USB_MOUNT
274
-                if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
275
-                    shred -zu ${1}/*
276
-                    rm -rf ${1}
277
-                fi
278
-                function_check restart_site
279
-                restart_site
280
-                exit 683252
281
-            fi
282
-        fi
283
-        echo "$BACKUP_DUMMY_PASSWORD" | obnam forget --keep=30d -r $USB_MOUNT/backup/${2} --encrypt-with $MY_BACKUP_KEY_ID
284
-        if [ ! "$?" = "0" ]; then
285
-            umount $USB_MOUNT
286
-            rm -rf $USB_MOUNT
287
-            if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
288
-                shred -zu ${1}/*
289
-                rm -rf ${1}
290
-            fi
291
-            function_check restart_site
292
-            restart_site
293
-            exit 7
294
-        fi
346
+
347
+        backup_directory_to_usb_duplicity ${1} ${2}
348
+        #backup_directory_to_usb_obnam ${1} ${2}
349
+
295
         if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
350
         if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
296
             shred -zu ${1}/*
351
             shred -zu ${1}/*
297
             rm -rf ${1}
352
             rm -rf ${1}
299
     fi
354
     fi
300
 }
355
 }
301
 
356
 
357
+function restore_directory_from_usb_obnam {
358
+    set_obnam_client_name
359
+    echo "$BACKUP_DUMMY_PASSWORD" | obnam restore -r $USB_MOUNT/backup/${2} --to ${1}
360
+}
361
+
362
+function restore_directory_from_usb_duplicity {
363
+    create_backups_temp_directory
364
+    PASSPHRASE="$BACKUP_DUMMY_PASSWORD" duplicity restore --gpg-options "$BACKUP_GPG_OPTIONS" --tempdir $BACKUP_TEMP_DIRECTORY --force file://$USB_MOUNT/backup/${2} ${1}
365
+    if [ ! "$?" = "0" ]; then
366
+        echo "WARNING: failed to restore $USB_MOUNT/backup/${2} to ${1}"
367
+    fi
368
+    PASSPHRASE=
369
+    remove_backups_temp_directory
370
+}
371
+
302
 function restore_directory_from_usb {
372
 function restore_directory_from_usb {
303
     if [ ! ${1} ]; then
373
     if [ ! ${1} ]; then
304
-        echo "obnam restore -r $USB_MOUNT/backup/${2} --to ${1}"
374
+        echo "$USB_MOUNT/backup/${2} -> ${1}"
305
         echo $'No restore destination given'
375
         echo $'No restore destination given'
306
         return
376
         return
307
     fi
377
     fi
308
     if [ ! ${2} ]; then
378
     if [ ! ${2} ]; then
309
-        echo "obnam restore -r $USB_MOUNT/backup/${2} --to ${1}"
379
+        echo "$USB_MOUNT/backup/${2} -> ${1}"
310
         echo $'No restore source given'
380
         echo $'No restore source given'
311
         return
381
         return
312
     fi
382
     fi
313
     if [ ! -d ${1} ]; then
383
     if [ ! -d ${1} ]; then
314
         mkdir ${1}
384
         mkdir ${1}
315
     fi
385
     fi
386
+    restore_directory_from_usb_duplicity ${1} ${2}
387
+    #restore_directory_from_usb_obnam ${1} ${2}
388
+}
389
+
390
+function restore_directory_from_friend_obnam {
316
     set_obnam_client_name
391
     set_obnam_client_name
317
-    echo "$BACKUP_DUMMY_PASSWORD" | obnam restore -r $USB_MOUNT/backup/${2} --to ${1}
392
+    echo "$BACKUP_DUMMY_PASSWORD" | obnam restore -r $SERVER_DIRECTORY/backup/${2} --to ${1}
393
+}
394
+
395
+function restore_directory_from_friend_duplicity {
396
+    create_backups_temp_directory
397
+    PASSPHRASE="$BACKUP_DUMMY_PASSWORD" duplicity restore --gpg-options "$BACKUP_GPG_OPTIONS" --tempdir $BACKUP_TEMP_DIRECTORY --force file://$SERVER_DIRECTORY/backup/${2} ${1}
398
+    PASSPHRASE=
399
+    remove_backups_temp_directory
318
 }
400
 }
319
 
401
 
320
 function restore_directory_from_friend {
402
 function restore_directory_from_friend {
331
     if [ ! -d ${1} ]; then
413
     if [ ! -d ${1} ]; then
332
         mkdir ${1}
414
         mkdir ${1}
333
     fi
415
     fi
334
-    set_obnam_client_name
335
-    echo "$BACKUP_DUMMY_PASSWORD" | obnam restore -r $SERVER_DIRECTORY/backup/${2} --to ${1}
416
+    restore_directory_from_friend_duplicity ${1} ${2}
417
+    #restore_directory_from_friend_obnam ${1} ${2}
336
 }
418
 }
337
 
419
 
338
 function backup_database_to_usb {
420
 function backup_database_to_usb {
357
     done
439
     done
358
 }
440
 }
359
 
441
 
360
-function backup_directory_to_friend {
361
-    BACKUP_KEY_EXISTS=$(gpg --list-keys "$ADMIN_NAME (backup key)")
442
+function backup_directory_to_friend_duplicity {
443
+    create_backups_temp_directory
444
+    echo "$BACKUP_DUMMY_PASSWORD" | duplicity full --gpg-options "$BACKUP_GPG_OPTIONS" --tempdir $BACKUP_TEMP_DIRECTORY --ssh-askpass --encrypt-key ${ADMIN_BACKUP_KEY_ID} --full-if-older-than 4W --exclude-other-filesystems ${1} $SERVER_DIRECTORY/backup/${2}
362
     if [ ! "$?" = "0" ]; then
445
     if [ ! "$?" = "0" ]; then
363
-        echo $"Backup key could not be found"
446
+        if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
447
+            shred -zu ${1}/*
448
+            rm -rf ${1}
449
+        fi
364
         function_check restart_site
450
         function_check restart_site
365
         restart_site
451
         restart_site
366
-        exit 43382
452
+        remove_backups_temp_directory
453
+        exit 5293526
367
     fi
454
     fi
368
-
369
-    ADMIN_BACKUP_KEY_ID=$(gpg --list-keys "$ADMIN_NAME (backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
370
-    if [ ! -d $SERVER_DIRECTORY/backup/${2} ]; then
371
-        mkdir -p $SERVER_DIRECTORY/backup/${2}
455
+    if [[ $ENABLE_BACKUP_VERIFICATION == "yes" ]]; then
456
+        echo "$BACKUP_DUMMY_PASSWORD" | duplicity verify --gpg-options "$BACKUP_GPG_OPTIONS" --tempdir $BACKUP_TEMP_DIRECTORY --ssh-askpass --encrypt-key ${ADMIN_BACKUP_KEY_ID} --full-if-older-than 4W --exclude-other-filesystems ${1} $SERVER_DIRECTORY/backup/${2}
457
+        if [ ! "$?" = "0" ]; then
458
+            if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
459
+                shred -zu ${1}/*
460
+                rm -rf ${1}
461
+            fi
462
+            function_check restart_site
463
+            restart_site
464
+            remove_backups_temp_directory
465
+            exit 683252
466
+        fi
372
     fi
467
     fi
468
+    remove_backups_temp_directory
469
+}
470
+
471
+function backup_directory_to_friend_obnam {
373
     set_obnam_client_name
472
     set_obnam_client_name
374
     echo "$BACKUP_DUMMY_PASSWORD" | obnam force-lock -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
473
     echo "$BACKUP_DUMMY_PASSWORD" | obnam force-lock -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
375
     echo "$BACKUP_DUMMY_PASSWORD" | obnam backup -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
474
     echo "$BACKUP_DUMMY_PASSWORD" | obnam backup -r $SERVER_DIRECTORY/backup/${2} --encrypt-with ${ADMIN_BACKUP_KEY_ID} ${1}
399
         restart_site
498
         restart_site
400
         exit 853
499
         exit 853
401
     fi
500
     fi
501
+}
502
+
503
+function backup_directory_to_friend {
504
+    BACKUP_KEY_EXISTS=$(gpg --list-keys "$ADMIN_NAME (backup key)")
505
+    if [ ! "$?" = "0" ]; then
506
+        echo $"Backup key could not be found"
507
+        function_check restart_site
508
+        restart_site
509
+        exit 43382
510
+    fi
511
+
512
+    ADMIN_BACKUP_KEY_ID=$(gpg --list-keys "$ADMIN_NAME (backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
513
+    if [ ! -d $SERVER_DIRECTORY/backup/${2} ]; then
514
+        mkdir -p $SERVER_DIRECTORY/backup/${2}
515
+    fi
516
+
517
+    backup_directory_to_friend_duplicity ${1} ${2}
518
+    #backup_directory_to_friend_obnam ${1} ${2}
519
+
402
     if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
520
     if [[ ${1} == "/root/temp"* || ${1} == *"tempbackup" ]]; then
403
         shred -zu /root/temp${2}/*
521
         shred -zu /root/temp${2}/*
404
         rm -rf /root/temp${2}
522
         rm -rf /root/temp${2}
510
         echo $"Restoring ${1} database"
628
         echo $"Restoring ${1} database"
511
         local_database_dir=/root/temp${1}data
629
         local_database_dir=/root/temp${1}data
512
         restore_directory_from_friend ${local_database_dir} ${1}data
630
         restore_directory_from_friend ${local_database_dir} ${1}data
513
-        if [ ! -f ${local_database_dir}/${RESTORE_SUBDIR}/temp${1}data/${1}.sql ]; then
631
+        database_file=${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data/${restore_app_name}.sql
632
+        if [ ! -f $database_file ]; then
633
+            database_file=${local_database_dir}/${restore_app_name}.sql
634
+        fi
635
+        if [ ! -f $database_file ]; then
514
             echo $"Unable to restore ${1} database"
636
             echo $"Unable to restore ${1} database"
515
             rm -rf ${local_database_dir}
637
             rm -rf ${local_database_dir}
516
             exit 503
638
             exit 503
521
             echo "$mysqlsuccess"
643
             echo "$mysqlsuccess"
522
             exit 964
644
             exit 964
523
         fi
645
         fi
524
-        shred -zu ${local_database_dir}/${RESTORE_SUBDIR}/temp${1}data/*
646
+        if [ -d ${local_database_dir}/${RESTORE_SUBDIR}/temp${1}data ]; then
647
+            shred -zu ${local_database_dir}/${RESTORE_SUBDIR}/temp${1}data/*
648
+        else
649
+            shred -zu ${local_database_dir}/*.sql
650
+        fi
525
         rm -rf ${local_database_dir}
651
         rm -rf ${local_database_dir}
526
         echo $"Restoring ${1} installation"
652
         echo $"Restoring ${1} installation"
527
         restore_directory_from_friend /root/temp${1} ${1}
653
         restore_directory_from_friend /root/temp${1} ${1}
528
         RESTORE_SUBDIR="var"
654
         RESTORE_SUBDIR="var"
529
         if [ ${1} ]; then
655
         if [ ${1} ]; then
656
+            # create directory to restore to
530
             if [ ! -d /var/www/${2}/htdocs ]; then
657
             if [ ! -d /var/www/${2}/htdocs ]; then
531
                 mkdir -p /var/www/${2}/htdocs
658
                 mkdir -p /var/www/${2}/htdocs
532
                 chown www-data:www-data /var/www/${2}/htdocs
659
                 chown www-data:www-data /var/www/${2}/htdocs
533
             fi
660
             fi
534
 
661
 
535
             if [ -d /var/www/${2}/htdocs ]; then
662
             if [ -d /var/www/${2}/htdocs ]; then
536
-                if [ -d /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs ]; then
537
-                    rm -rf /var/www/${2}/htdocs
538
-                    mv /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs /var/www/${2}/
663
+                restore_from_dir=/root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs
664
+                if [ ! -d /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs ]; then
665
+                    restore_from_dir=/root/temp${1}
666
+                fi
667
+
668
+                if [ -d $restore_from_dir ]; then
669
+                    if [ -d /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs ]; then
670
+                        rm -rf /var/www/${2}/htdocs
671
+                        mv $restore_from_dir /var/www/${2}/
672
+                    else
673
+                        cp -r $restore_from_dir/* /var/www/${2}/htdocs/
674
+                    fi
539
                     if [ ! "$?" = "0" ]; then
675
                     if [ ! "$?" = "0" ]; then
540
                         exit 683
676
                         exit 683
541
                     fi
677
                     fi
567
         fi
703
         fi
568
         function_check restore_directory_from_usb
704
         function_check restore_directory_from_usb
569
         restore_directory_from_usb "${local_database_dir}" "${restore_app_name}data"
705
         restore_directory_from_usb "${local_database_dir}" "${restore_app_name}data"
570
-        if [ ! -f /root/temp${restore_app_name}data/${RESTORE_SUBDIR}/temp${restore_app_name}data/${restore_app_name}.sql ]; then
706
+        database_file=${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data/${restore_app_name}.sql
707
+        if [ ! -f $database_file ]; then
708
+            database_file=${local_database_dir}/${restore_app_name}.sql
709
+        fi
710
+        if [ ! -f $database_file ]; then
571
             echo $"Unable to restore ${restore_app_name} database"
711
             echo $"Unable to restore ${restore_app_name} database"
572
             rm -rf ${local_database_dir}
712
             rm -rf ${local_database_dir}
573
             function_check set_user_permissions
713
             function_check set_user_permissions
577
             exit 503
717
             exit 503
578
         fi
718
         fi
579
         keep_database_running
719
         keep_database_running
580
-        mysqlsuccess=$(mysql -u root --password="$DATABASE_PASSWORD" ${restore_app_name} -o < ${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data/${restore_app_name}.sql)
720
+        mysqlsuccess=$(mysql -u root --password="$DATABASE_PASSWORD" ${restore_app_name} -o < $database_file)
581
         if [ ! "$?" = "0" ]; then
721
         if [ ! "$?" = "0" ]; then
582
             echo "$mysqlsuccess"
722
             echo "$mysqlsuccess"
583
             function_check set_user_permissions
723
             function_check set_user_permissions
586
             backup_unmount_drive
726
             backup_unmount_drive
587
             exit 964
727
             exit 964
588
         fi
728
         fi
589
-        shred -zu ${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data/*
729
+        if [ -d ${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data ]; then
730
+            shred -zu ${local_database_dir}/${RESTORE_SUBDIR}/temp${restore_app_name}data/*
731
+        else
732
+            shred -zu ${local_database_dir}/*.sql
733
+        fi
734
+
590
         rm -rf ${local_database_dir}
735
         rm -rf ${local_database_dir}
591
         echo $"Restoring ${restore_app_name} installation"
736
         echo $"Restoring ${restore_app_name} installation"
592
         if [ ! -d /root/temp${restore_app_name} ]; then
737
         if [ ! -d /root/temp${restore_app_name} ]; then
596
         restore_directory_from_usb "/root/temp${restore_app_name}" "${restore_app_name}"
741
         restore_directory_from_usb "/root/temp${restore_app_name}" "${restore_app_name}"
597
         RESTORE_SUBDIR="var"
742
         RESTORE_SUBDIR="var"
598
         if [ ${restore_app_domain} ]; then
743
         if [ ${restore_app_domain} ]; then
744
+            # create directory to restore to
599
             if [ ! -d /var/www/${restore_app_domain}/htdocs ]; then
745
             if [ ! -d /var/www/${restore_app_domain}/htdocs ]; then
600
                 mkdir -p /var/www/${restore_app_domain}/htdocs
746
                 mkdir -p /var/www/${restore_app_domain}/htdocs
601
                 chown www-data:www-data /var/www/${restore_app_domain}/htdocs
747
                 chown www-data:www-data /var/www/${restore_app_domain}/htdocs
602
             fi
748
             fi
749
+
603
             if [ -d /var/www/${restore_app_domain}/htdocs ]; then
750
             if [ -d /var/www/${restore_app_domain}/htdocs ]; then
604
-                if [ -d /root/temp${restore_app_name}/${RESTORE_SUBDIR}/www/${restore_app_domain}/htdocs ]; then
605
-                    rm -rf /var/www/${restore_app_domain}/htdocs
606
-                    mv /root/temp${restore_app_name}/${RESTORE_SUBDIR}/www/${restore_app_domain}/htdocs /var/www/${restore_app_domain}/
751
+                restore_from_dir=/root/temp${restore_app_name}/${RESTORE_SUBDIR}/www/${restore_app_domain}/htdocs
752
+                if [ ! -d $restore_from_dir ]; then
753
+                    restore_from_dir=/root/temp${restore_app_name}
754
+                fi
755
+                if [ -d $restore_from_dir ]; then
756
+                    if [ -d /root/temp${restore_app_name}/${RESTORE_SUBDIR}/www/${restore_app_domain}/htdocs ]; then
757
+                        rm -rf /var/www/${restore_app_domain}/htdocs
758
+                        mv $restore_from_dir /var/www/${restore_app_domain}/
759
+                    else
760
+                        cp -r $restore_from_dir/* /var/www/${restore_app_domain}/htdocs/
761
+                    fi
607
                     if [ ! "$?" = "0" ]; then
762
                     if [ ! "$?" = "0" ]; then
608
                         set_user_permissions
763
                         set_user_permissions
609
                         backup_unmount_drive
764
                         backup_unmount_drive

+ 95
- 0
src/freedombone-utils-guile 查看文件

1
+#!/bin/bash
2
+#
3
+# .---.                  .              .
4
+# |                      |              |
5
+# |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-.
6
+# |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-'
7
+# '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --'
8
+#
9
+#                    Freedom in the Cloud
10
+#
11
+# Recent version of guile
12
+#
13
+# License
14
+# =======
15
+#
16
+# Copyright (C) 2017 Bob Mottram <bob@freedombone.net>
17
+#
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
20
+# the Free Software Foundation, either version 3 of the License, or
21
+# (at your option) any later version.
22
+#
23
+# This program is distributed in the hope that it will be useful,
24
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
25
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
26
+# GNU Affero General Public License for more details.
27
+#
28
+# You should have received a copy of the GNU Affero General Public License
29
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
30
+
31
+GUILE_VERSION='2.2.0'
32
+GUILE_HASH='c707b9cf6f97ecca3a4e3e704e62b83f95f1aec28ed1535f5d0a1d36af07a015'
33
+
34
+EIGHTSYNC_REPO="git://git.savannah.gnu.org/8sync.git"
35
+EIGHTSYNC_COMMIT='8cbb7f22227c0afdd3b0bd758ebec0efba2fa1e1'
36
+
37
+function install_8sync {
38
+    apt-get -qy install flex libunistring-dev libgc-dev autoconf texinfo
39
+
40
+    if [ ! -d $INSTALL_DIR ]; then
41
+        mkdir $INSTALL_DIR
42
+    fi
43
+    cd $INSTALL_DIR
44
+
45
+    git_clone $EIGHTSYNC_REPO $INSTALL_DIR/eightsync
46
+    cd $INSTALL_DIR/eightsync
47
+    git checkout ${EIGHTSYNC_COMMIT} -b ${EIGHTSYNC_COMMIT}
48
+
49
+    export GUILE_BASE_PATH=/opt/guile-${GUILE_VERSION}
50
+    export GUILE_CFLAGS="-I${GUILE_BASE_PATH}/include"
51
+    export GUILE_LIBS="-L${GUILE_BASE_PATH}/lib -lguile -lqthreads -ldl -ltermcap -lsocket -lnsl -lm"
52
+    ./bootstrap.sh
53
+    configure
54
+    make
55
+    make install
56
+}
57
+
58
+function install_guile {
59
+    # Currently this only works for x86_64
60
+    read_config_param ARCHITECTURE
61
+    if [[ ${ARCHITECTURE} != "x86_64" ]]; then
62
+        return
63
+    fi
64
+    GUILE_ARCH='x86_64'
65
+
66
+    apt-get -qy install flex libunistring-dev libgc-dev autoconf texinfo lzip wget
67
+
68
+    if [ ! -d $INSTALL_DIR ]; then
69
+        mkdir $INSTALL_DIR
70
+    fi
71
+    cd $INSTALL_DIR
72
+
73
+    if [ ! -f guile-${GUILE_VERSION}-pack-${GUILE_ARCH}-linux-gnu.tar.lz ]; then
74
+        wget https://ftp.gnu.org/gnu/guile/guile-${GUILE_VERSION}-pack-${GUILE_ARCH}-linux-gnu.tar.lz
75
+    fi
76
+    if [ ! -f guile-${GUILE_VERSION}-pack-${GUILE_ARCH}-linux-gnu.tar.lz ]; then
77
+        echo 'Unable to download guile pack'
78
+        exit 6735238
79
+    fi
80
+    CURR_GUILE_HASH=$(sha256sum guile-${GUILE_VERSION}-pack-${GUILE_ARCH}-linux-gnu.tar.lz | awk -F ' ' '{print $1}')
81
+    if [[ "$CURR_GUILE_HASH" != "$GUILE_HASH" ]]; then
82
+        echo 'Guile hash does not match'
83
+        exit 7237625
84
+    fi
85
+    cd /
86
+    tar xvf $INSTALL_DIR/guile-${GUILE_VERSION}-pack-${GUILE_ARCH}-linux-gnu.tar.lz
87
+    if [ ! -d /opt/guile-${GUILE_VERSION}/bin ]; then
88
+        echo 'Guile was not installed'
89
+        exit 825269
90
+    fi
91
+    echo "export GUILE_PATH=/opt/guile-${GUILE_VERSION}/bin" >> ~/.bashrc
92
+    echo 'export PATH=$PATH:$GUILE_PATH' >> ~/.bashrc
93
+}
94
+
95
+# NOTE: deliberately no exit 0

+ 1
- 1
src/freedombone-utils-setup 查看文件

260
     apt-get -yq dist-upgrade
260
     apt-get -yq dist-upgrade
261
     apt-get -yq install ca-certificates
261
     apt-get -yq install ca-certificates
262
     apt-get -yq install apt-utils
262
     apt-get -yq install apt-utils
263
-    apt-get -yq install cryptsetup libgfshare-bin obnam sshpass wget avahi-daemon
263
+    apt-get -yq install cryptsetup libgfshare-bin duplicity sshpass wget avahi-daemon
264
     apt-get -yq install avahi-utils avahi-discover connect-proxy openssh-server
264
     apt-get -yq install avahi-utils avahi-discover connect-proxy openssh-server
265
     apt-get -yq install sudo git dialog build-essential avahi-daemon avahi-utils
265
     apt-get -yq install sudo git dialog build-essential avahi-daemon avahi-utils
266
     apt-get -yq install avahi-discover avahi-autoipd iptables dnsutils net-tools
266
     apt-get -yq install avahi-discover avahi-autoipd iptables dnsutils net-tools

+ 14
- 10
website/EN/app_matrix.html 查看文件

3
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
4
 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
5
 <head>
5
 <head>
6
-<!-- 2017-05-10 Wed 20:25 -->
6
+<!-- 2017-08-23 Wed 19:23 -->
7
 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
7
 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
8
 <meta name="viewport" content="width=device-width, initial-scale=1" />
8
 <meta name="viewport" content="width=device-width, initial-scale=1" />
9
 <title></title>
9
 <title></title>
260
 Matrix is a federated communications system, typically for multi-user chat, with end-to-end content security features. You can consider it to be like a modernized version of IRC chat where the crypto and access controls have been built in by default. At present Matrix is really only a creature of the clearnet and so there isn't any way to protect the metadata. Despite the talk of security the lack of metadata defenses make this really only suitable for public communications, similar to microblogging or public IRC channels.
260
 Matrix is a federated communications system, typically for multi-user chat, with end-to-end content security features. You can consider it to be like a modernized version of IRC chat where the crypto and access controls have been built in by default. At present Matrix is really only a creature of the clearnet and so there isn't any way to protect the metadata. Despite the talk of security the lack of metadata defenses make this really only suitable for public communications, similar to microblogging or public IRC channels.
261
 </p>
261
 </p>
262
 
262
 
263
-<div id="outline-container-orgc5ac459" class="outline-2">
264
-<h2 id="orgc5ac459">Installation</h2>
265
-<div class="outline-text-2" id="text-orgc5ac459">
263
+<p>
264
+Another consideration is that since matrix operates on the usual HTTPS port number (443) this may make it difficult for ISPs or governments to censor this type of communications via port blocking without significant blowback.
265
+</p>
266
+
267
+<div id="outline-container-orgc78770d" class="outline-2">
268
+<h2 id="orgc78770d">Installation</h2>
269
+<div class="outline-text-2" id="text-orgc78770d">
266
 <p>
270
 <p>
267
 Log into your system with:
271
 Log into your system with:
268
 </p>
272
 </p>
282
 </div>
286
 </div>
283
 </div>
287
 </div>
284
 
288
 
285
-<div id="outline-container-orgd4dad6a" class="outline-2">
286
-<h2 id="orgd4dad6a">Initial setup</h2>
287
-<div class="outline-text-2" id="text-orgd4dad6a">
289
+<div id="outline-container-org5262b52" class="outline-2">
290
+<h2 id="org5262b52">Initial setup</h2>
291
+<div class="outline-text-2" id="text-org5262b52">
288
 <p>
292
 <p>
289
 Go to the <b>Administrator control panel</b> and select <b>Passwords</b> then <b>matrix</b>. This will give you the password to initially log in to the system and you can change it later from a client app if needed.
293
 Go to the <b>Administrator control panel</b> and select <b>Passwords</b> then <b>matrix</b>. This will give you the password to initially log in to the system and you can change it later from a client app if needed.
290
 </p>
294
 </p>
299
 </div>
303
 </div>
300
 </div>
304
 </div>
301
 
305
 
302
-<div id="outline-container-org43f1308" class="outline-2">
303
-<h2 id="org43f1308">DNS setup</h2>
304
-<div class="outline-text-2" id="text-org43f1308">
306
+<div id="outline-container-orgd8eede9" class="outline-2">
307
+<h2 id="orgd8eede9">DNS setup</h2>
308
+<div class="outline-text-2" id="text-orgd8eede9">
305
 <p>
309
 <p>
306
 It's recommended that you add an SRV record for Matrix to your DNS setup. How you do this will depend upon your dynamic DNS provider and their web interface. On FreeDNS on the subdomains settings in addition to the subdomain which you are using for the matrix server create an extra entry as follows:
310
 It's recommended that you add an SRV record for Matrix to your DNS setup. How you do this will depend upon your dynamic DNS provider and their web interface. On FreeDNS on the subdomains settings in addition to the subdomain which you are using for the matrix server create an extra entry as follows:
307
 </p>
311
 </p>