From df9468a1a4e976784da7904b48fd2f08578f48ba Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@robotics.uk.to>
Date: Mon, 4 Jul 2016 19:14:03 +0100
Subject: [PATCH] Function to remove webmail

---
 src/freedombone-app-webmail | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/freedombone-app-webmail b/src/freedombone-app-webmail
index 4d06ffb86..ff8108885 100755
--- a/src/freedombone-app-webmail
+++ b/src/freedombone-app-webmail
@@ -33,15 +33,33 @@ WEBMAIL_COMMIT='78cf9c2e5cff2d78cd8beb647d60570f195a2a9c'
 WEBMAIL_ONION_HOSTNAME=
 WEBMAIL_ONION_PORT=8097
 WEBMAIL_ADMIN_PASSWORD=
+WEB_PATH=/var/www
+WEBMAIL_PATH=$WEB_PATH/webmail
+
+function remove_webmail {
+	if ! grep -Fxq "install_webmail" $COMPLETION_FILE; then
+		return
+	fi
+	nginx_dissite webmail
+	if [ -f /etc/nginx/sites-available/webmail ]; then
+		rm /etc/nginx/sites-available/webmail
+	fi
+	function_check remove_onion_service
+	remove_onion_service webmail ${WEBMAIL_ONION_PORT}
+	function_check drop_database
+	drop_database webmain
+	if [ -d $WEB_PATH/webmail ]; then
+		rm -rf $WEB_PATH/webmail
+	fi
+	sed -i '/Webmail /d' $COMPLETION_FILE
+	sed -i '/install_webmail/d' $COMPLETION_FILE
+}
 
 function install_webmail {
 	if [[ $SYSTEM_TYPE == "$VARIANT_CHAT" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
 		return
 	fi
 
-	WEB_PATH=/var/www
-	WEBMAIL_PATH=$WEB_PATH/webmail
-
 	# update to a new commit if needed
 	function_check set_repo_commit
 	set_repo_commit $WEBMAIL_PATH "Webmail commit" "$WEBMAIL_COMMIT" $WEBMAIL_REPO
-- 
GitLab