Pārlūkot izejas kodu

Move local wiki restore to app script

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

+ 42
- 0
src/freedombone-app-wiki Parādīt failu

@@ -54,10 +54,52 @@ function backup_local_wiki {
54 54
 	fi
55 55
 }
56 56
 
57
+function restore_local_wiki {
58
+	if [ -d /var/lib/dokuwiki ]; then
59
+		echo $"Restoring Wiki installation"
60
+		WIKI_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Wiki domain" | awk -F ':' '{print $2}')
61
+		temp_restore_dir=/root/tempwiki
62
+		function_check restore_directory_from_usb
63
+		restore_directory_from_usb $temp_restore_dir wiki
64
+		cp -r $temp_restore_dir/var/lib/dokuwiki/* /var/lib/dokuwiki/
65
+		if [ ! "$?" = "0" ]; then
66
+			function_check restore_directory_from_usb
67
+			set_user_permissions
68
+			function_check backup_unmount_drive
69
+			backup_unmount_drive
70
+			exit 868
71
+		fi
72
+		restore_directory_from_usb ${temp_restore_dir}2 wiki2
73
+		cp -r ${temp_restore_dir}2/etc/dokuwiki/* /etc/dokuwiki/
74
+		if [ ! "$?" = "0" ]; then
75
+			function_check set_user_permissions
76
+			set_user_permissions
77
+			function_check backup_unmount_drive
78
+			backup_unmount_drive
79
+			exit 869
80
+		fi
81
+		rm -rf $temp_restore_dir
82
+		rm -rf ${temp_restore_dir}2
83
+		chown -R www-data:www-data /var/lib/dokuwiki/*
84
+		# Ensure that the bundled SSL cert is being used
85
+		if [ -f /etc/ssl/certs/${WIKI_DOMAIN_NAME}.bundle.crt ]; then
86
+			sed -i "s|${WIKI_DOMAIN_NAME}.crt|${WIKI_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${WIKI_DOMAIN_NAME}
87
+		fi
88
+		if [ -d /etc/letsencrypt/live/${WIKI_DOMAIN_NAME} ]; then
89
+			ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${WIKI_DOMAIN_NAME}.key
90
+			ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${WIKI_DOMAIN_NAME}.pem
91
+		fi
92
+	fi
93
+}
94
+
57 95
 function backup_remote_wiki {
58 96
 	echo -n ''
59 97
 }
60 98
 
99
+function restore_remote_wiki {
100
+	echo -n ''
101
+}
102
+
61 103
 function remove_wiki {
62 104
 	if ! grep -Fxq "install_wiki" $COMPLETION_FILE; then
63 105
 		return

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

@@ -1034,42 +1034,6 @@ function restore_gogs {
1034 1034
     fi
1035 1035
 }
1036 1036
 
1037
-function restore_wiki {
1038
-    if [[ $RESTORE_APP != 'all' ]]; then
1039
-        if [[ $RESTORE_APP != 'wiki' ]]; then
1040
-            return
1041
-        fi
1042
-    fi
1043
-    if [ $WIKI_DOMAIN_NAME ]; then
1044
-        echo $"Restoring Wiki installation ${WIKI_DOMAIN_NAME}"
1045
-        restore_directory_from_usb /root/tempwiki wiki
1046
-        cp -r /root/tempwiki/var/lib/dokuwiki/* /var/lib/dokuwiki/
1047
-        if [ ! "$?" = "0" ]; then
1048
-            set_user_permissions
1049
-            backup_unmount_drive
1050
-            exit 868
1051
-        fi
1052
-        restore_directory_from_usb /root/tempwiki2 wiki2
1053
-        cp -r /root/tempwiki2/etc/dokuwiki/* /etc/dokuwiki/
1054
-        if [ ! "$?" = "0" ]; then
1055
-            set_user_permissions
1056
-            backup_unmount_drive
1057
-            exit 869
1058
-        fi
1059
-        rm -rf /root/tempwiki
1060
-        rm -rf /root/tempwiki2
1061
-        chown -R www-data:www-data /var/lib/dokuwiki/*
1062
-        # Ensure that the bundled SSL cert is being used
1063
-        if [ -f /etc/ssl/certs/${WIKI_DOMAIN_NAME}.bundle.crt ]; then
1064
-            sed -i "s|${WIKI_DOMAIN_NAME}.crt|${WIKI_DOMAIN_NAME}.bundle.crt|g" /etc/nginx/sites-available/${WIKI_DOMAIN_NAME}
1065
-        fi
1066
-        if [ -d /etc/letsencrypt/live/${WIKI_DOMAIN_NAME} ]; then
1067
-            ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${WIKI_DOMAIN_NAME}.key
1068
-            ln -s /etc/letsencrypt/live/${WIKI_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${WIKI_DOMAIN_NAME}.pem
1069
-        fi
1070
-    fi
1071
-}
1072
-
1073 1037
 function restore_email {
1074 1038
     if [[ $RESTORE_APP != 'all' ]]; then
1075 1039
         if [[ $RESTORE_APP != 'email' ]]; then
@@ -1165,7 +1129,6 @@ restore_rss
1165 1129
 restore_syncthing
1166 1130
 restore_mediagoblin
1167 1131
 restore_gogs
1168
-restore_wiki
1169 1132
 
1170 1133
 restore_email
1171 1134
 restore_apps