Quellcode durchsuchen

Function to remove wiki

Bob Mottram vor 8 Jahren
Ursprung
Commit
eadc7fc342
1 geänderte Dateien mit 30 neuen und 4 gelöschten Zeilen
  1. 30
    4
      src/freedombone-app-wiki

+ 30
- 4
src/freedombone-app-wiki Datei anzeigen

@@ -34,6 +34,32 @@ WIKI_TITLE="${PROJECT_NAME} Wiki"
34 34
 WIKI_CODE=
35 35
 WIKI_ONION_PORT=8089
36 36
 
37
+function remove_wiki {
38
+	if ! grep -Fxq "install_wiki" $COMPLETION_FILE; then
39
+		return
40
+	fi
41
+	function_check remove_onion_service
42
+	remove_onion_service wiki ${WIKI_ONION_PORT}
43
+	nginx_dissite $WIKI_DOMAIN_NAME
44
+	if [ -f /etc/nginx/sites-available/$WIKI_DOMAIN_NAME ]; then
45
+		rm /etc/nginx/sites-available/$WIKI_DOMAIN_NAME
46
+	fi
47
+	apt-get -y remove --purge dokuwiki
48
+	if [ ! -d /var/www/$WIKI_DOMAIN_NAME ]; then
49
+		rm -rf /var/www/$WIKI_DOMAIN_NAME
50
+	fi
51
+	if [ -d /var/lib/dokuwiki ]; then
52
+		rm -rf /var/lib/dokuwiki
53
+	fi
54
+	if [ -d /etc/dokuwiki ]; then
55
+		rm -rf /etc/dokuwiki
56
+	fi
57
+	if [ -d /usr/share/dokuwiki ]; then
58
+		rm -rf /usr/share/dokuwiki
59
+	fi
60
+	sed -i '/install_wiki/d' $COMPLETION_FILE
61
+}
62
+
37 63
 function get_wiki_admin_password {
38 64
 	if [ -f /home/$MY_USERNAME/README ]; then
39 65
 		if grep -q "Wiki password" /home/$MY_USERNAME/README; then
@@ -102,7 +128,7 @@ function install_wiki {
102 128
 		echo "\$conf['authtype'] = 'authplain';" >> /etc/dokuwiki/local.php
103 129
 	fi
104 130
 
105
-    function_check get_wiki_admin_password
131
+	function_check get_wiki_admin_password
106 132
 	get_wiki_admin_password
107 133
 	if [ ! $WIKI_ADMIN_PASSWORD ]; then
108 134
 		if [ -f $IMAGE_PASSWORD_FILE ]; then
@@ -372,10 +398,10 @@ function install_wiki {
372 398
 	echo '    }' >> /etc/nginx/sites-available/$WIKI_DOMAIN_NAME
373 399
 	echo '}' >> /etc/nginx/sites-available/$WIKI_DOMAIN_NAME
374 400
 
375
-    function_check create_site_certificate
401
+	function_check create_site_certificate
376 402
 	create_site_certificate $WIKI_DOMAIN_NAME
377 403
 
378
-    function_check configure_php
404
+	function_check configure_php
379 405
 	configure_php
380 406
 
381 407
 	nginx_ensite $WIKI_DOMAIN_NAME
@@ -385,7 +411,7 @@ function install_wiki {
385 411
 
386 412
 	echo "Wiki onion domain:${WIKI_ONION_HOSTNAME}" >> $COMPLETION_FILE
387 413
 
388
-    function_check add_ddns_domain
414
+	function_check add_ddns_domain
389 415
 	add_ddns_domain $WIKI_DOMAIN_NAME
390 416
 
391 417
 	# add some post-install instructions