From 6ee7845b19ac328e1eae0d3dea6128858985f70f Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@robotics.uk.to>
Date: Sun, 6 Jan 2019 21:32:33 +0000
Subject: [PATCH] Onion rync integration

---
 src/freedombone-app-rsync | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/freedombone-app-rsync b/src/freedombone-app-rsync
index 0ef027802..197db3e19 100755
--- a/src/freedombone-app-rsync
+++ b/src/freedombone-app-rsync
@@ -44,7 +44,6 @@ NOT_ON_HOMEPAGE=1
 
 RSYNC_DOMAIN_NAME=
 RSYNC_CODE=
-RSYNC_ONION_PORT=9951
 RSYNC_PORT=873
 
 # These parameters are used by the FreedomBox mobile app and web UI
@@ -134,6 +133,11 @@ function remove_rsync {
     userdel -r rsync
     rm -rf "$RSYNC_DATA"
 
+    if grep -q "127.0.0.1:$RSYNC_PORT" "/etc/torrc.d/${PROJECT_NAME}"; then
+        sed -i "/127.0.0.1:$RSYNC_PORT/d" "/etc/torrc.d/${PROJECT_NAME}"
+        systemctl restart tor
+    fi
+
     remove_app rsync
     remove_completion_param install_rsync
     sed -i '/rsync/d' "$COMPLETION_FILE"
@@ -194,6 +198,11 @@ function install_rsync {
 
     increment_app_install_progress
 
+    if ! grep -q "127.0.0.1:$RSYNC_PORT" "/etc/torrc.d/${PROJECT_NAME}"; then
+        sed -i "/127.0.0.1:5783/a HiddenServicePort $RSYNC_PORT 127.0.0.1:$RSYNC_PORT" "/etc/torrc.d/${PROJECT_NAME}"
+        systemctl restart tor
+    fi
+
     systemctl enable rsync
     systemctl start rsync
 
-- 
GitLab