From f19b65bd8fa24d24b1402ccfb90697450a7d36fe Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@robotics.uk.to>
Date: Sat, 9 Jul 2016 10:40:36 +0100
Subject: [PATCH] Move hubzilla local restore to app script

---
 src/freedombone-app-hubzilla  | 28 ++++++++++++++++++++++++++++
 src/freedombone-restore-local | 22 ----------------------
 2 files changed, 28 insertions(+), 22 deletions(-)

diff --git a/src/freedombone-app-hubzilla b/src/freedombone-app-hubzilla
index 1d1faca75..ac94a55b7 100755
--- a/src/freedombone-app-hubzilla
+++ b/src/freedombone-app-hubzilla
@@ -76,10 +76,38 @@ function backup_local_hubzilla {
 	fi
 }
 
+function restore_local_hubzilla {
+	if ! grep -q "Hubzilla domain" $COMPLETION_FILE; then
+		return
+	fi
+	HUBZILLA_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Hubzilla domain" | awk -F ':' '{print $2}')
+	if [ $HUBZILLA_DOMAIN_NAME ]; then
+		echo $"Restoring Hubzilla"
+		temp_restore_dir=/root/temphubzilla
+		hubzilla_dir=/var/www/${HUBZILLA_DOMAIN_NAME}/htdocs
+		restore_database hubzilla ${HUBZILLA_DOMAIN_NAME}
+		if [ -d $USB_MOUNT/backup/hubzilla ]; then
+			if [ ! -d $hubzilla_dir/store/[data]/smarty3 ]; then
+				mkdir -p $hubzilla_dir/store/[data]/smarty3
+			fi
+			chmod 777 $hubzilla_dir/store/[data]/smarty3
+			chown -R www-data:www-data $hubzilla_dir/*
+			if [ -d $temp_restore_dir ]; then
+				rm -rf $temp_restore_dir
+			fi
+		fi
+		echo $"Restore of Hubzilla complete"
+	fi
+}
+
 function backup_remote_hubzilla {
 	echo -n ''
 }
 
+function restore_remote_hubzilla {
+	echo -n ''
+}
+
 function remove_hubzilla {
 	if ! grep -Fxq "install_hubzilla" $COMPLETION_FILE; then
 		return
diff --git a/src/freedombone-restore-local b/src/freedombone-restore-local
index 23bd65556..6e7909e06 100755
--- a/src/freedombone-restore-local
+++ b/src/freedombone-restore-local
@@ -840,27 +840,6 @@ function restore_gnusocial {
     fi
 }
 
-function restore_hubzilla {
-    if [[ $RESTORE_APP != 'all' ]]; then
-        if [[ $RESTORE_APP != 'hubzilla' ]]; then
-            return
-        fi
-    fi
-    if [ $HUBZILLA_DOMAIN_NAME ]; then
-        restore_database hubzilla ${HUBZILLA_DOMAIN_NAME}
-        if [ -d $USB_MOUNT/backup/hubzilla ]; then
-            if [ ! -d /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3 ]; then
-                mkdir -p /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3
-            fi
-            chmod 777 /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/store/[data]/smarty3
-            chown -R www-data:www-data /var/www/${HUBZILLA_DOMAIN_NAME}/htdocs/*
-            if [ -d /root/temphubzilla ]; then
-                rm -rf /root/temphubzilla
-            fi
-        fi
-    fi
-}
-
 function restore_email {
     if [[ $RESTORE_APP != 'all' ]]; then
         if [[ $RESTORE_APP != 'email' ]]; then
@@ -951,7 +930,6 @@ restore_mailing_list
 restore_ipfs
 restore_xmpp
 restore_gnusocial
-restore_hubzilla
 
 restore_email
 restore_apps
-- 
GitLab