Browse Source

Restoring blog directory

Bob Mottram 8 years ago
parent
commit
58d1b6e16f
1 changed files with 20 additions and 14 deletions
  1. 20
    14
      src/freedombone-app-htmly

+ 20
- 14
src/freedombone-app-htmly View File

@@ -42,14 +42,14 @@ HTMLY_TITLE="My Htmly"
42 42
 HTMLY_SUBTITLE="Another ${PROJECT_NAME} Htmly"
43 43
 
44 44
 htmly_variables=(HTMLY_REPO
45
-                HTMLY_COMMIT
46
-                HTMLY_DOMAIN_NAME
47
-                HTMLY_CODE
48
-                HTMLY_TITLE
49
-                HTMLY_SUBTITLE
50
-                ONION_ONLY
51
-                DDNS_PROVIDER
52
-                MY_USERNAME)
45
+                 HTMLY_COMMIT
46
+                 HTMLY_DOMAIN_NAME
47
+                 HTMLY_CODE
48
+                 HTMLY_TITLE
49
+                 HTMLY_SUBTITLE
50
+                 ONION_ONLY
51
+                 DDNS_PROVIDER
52
+                 MY_USERNAME)
53 53
 
54 54
 function set_avatar_from_url {
55 55
     AVATAR="$1"
@@ -228,14 +228,17 @@ function restore_local_htmly {
228 228
         temp_restore_dir=/root/temphtmly
229 229
         restore_directory_from_usb $temp_restore_dir blog
230 230
         restore_directory_from_usb $temp_restore_dir htmly
231
-        rm -rf /var/www/${HTMLY_DOMAIN_NAME}/htdocs
232
-        cp -r $temp_restore_dir/var/www/${HTMLY_DOMAIN_NAME}/htdocs /var/www/${HTMLY_DOMAIN_NAME}/
231
+        if [ -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then
232
+            rm -rf /var/www/${HTMLY_DOMAIN_NAME}/htdocs
233
+        fi
234
+        temp_source_dir=$(find ${temp_restore_dir} -name htdocs | sed 's/\.//g')
235
+        cp -r ${temp_restore_dir}${temp_source_dir} /var/www/${HTMLY_DOMAIN_NAME}/
233 236
         if [ ! "$?" = "0" ]; then
234 237
             set_user_permissions
235 238
             backup_unmount_drive
236 239
             exit 593
237 240
         fi
238
-        rm -rf $temp_restore_dir
241
+        rm -rf ${temp_restore_dir}
239 242
         if [ ! -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs/content ]; then
240 243
             echo $"No content directory found after restoring htmly"
241 244
             set_user_permissions
@@ -285,12 +288,15 @@ function restore_remote_htmly {
285 288
         mkdir $temp_restore_dir
286 289
         function_check restore_directory_from_friend
287 290
         restore_directory_from_friend $temp_restore_dir htmly
288
-        rm -rf /var/www/${HTMLY_DOMAIN_NAME}/htdocs
289
-        cp -r $temp_restore_dir/var/www/${HTMLY_DOMAIN_NAME}/htdocs /var/www/${HTMLY_DOMAIN_NAME}/
291
+        if [ -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs ]; then
292
+            rm -rf /var/www/${HTMLY_DOMAIN_NAME}/htdocs
293
+        fi
294
+        temp_source_dir=$(find ${temp_restore_dir} -name htdocs | sed 's/\.//g')
295
+        cp -r ${temp_restore_dir}${temp_source_dir} /var/www/${HTMLY_DOMAIN_NAME}/
290 296
         if [ ! "$?" = "0" ]; then
291 297
             exit 593
292 298
         fi
293
-        rm -rf $temp_restore_dir
299
+        rm -rf ${temp_restore_dir}
294 300
         if [ ! -d /var/www/${HTMLY_DOMAIN_NAME}/htdocs/content ]; then
295 301
             echo $"No content directory found after restoring htmly"
296 302
             exit 287