From 9a72c76e234cce6d35264b932cab1097645db8d6 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob@freedombone.net>
Date: Tue, 15 May 2018 10:50:54 +0100
Subject: [PATCH] Make nextcloud server side encryption optional

---
 src/freedombone-app-nextcloud | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/src/freedombone-app-nextcloud b/src/freedombone-app-nextcloud
index 66802c9de..c17e2ef5a 100755
--- a/src/freedombone-app-nextcloud
+++ b/src/freedombone-app-nextcloud
@@ -40,6 +40,7 @@ NEXTCLOUD_REPO="https://github.com/nextcloud/server"
 # Stable 13 branch
 NEXTCLOUD_COMMIT='edd5712c6ead5b09fa4f996cfda66fc4e18ba597'
 NEXTCLOUD_ADMIN_PASSWORD=
+NEXTCLOUD_SERVER_SIDE_ENCRYPTION=1
 
 nextcloud_variables=(ONION_ONLY
                      NEXTCLOUD_DOMAIN_NAME
@@ -83,6 +84,16 @@ function install_interactive_nextcloud {
         ONION_ONLY='no'
     fi
 
+    dialog --title $"Enable NextCloud server side encryption" \
+           --backtitle $"Freedombone Configuration" \
+           --yesno $"\\nDo you want to enable server side encryption. On ARM or older x86 systems, especially without HRNG, this may make performance excessively slow?" 10 60
+    sel=$?
+    case $sel in
+        1) NEXTCLOUD_SERVER_SIDE_ENCRYPTION=
+           ;;
+        255) return;;
+    esac
+
     if [[ $ONION_ONLY != "no" ]]; then
         NEXTCLOUD_DOMAIN_NAME='nextcloud.local'
     else
@@ -668,12 +679,14 @@ function install_nextcloud_main {
     sudo -u www-data ./occ check
     sudo -u www-data ./occ status
     sudo -u www-data ./occ app:list
-    sudo -u www-data ./occ app:enable encryption
-    if ! sudo -u www-data ./occ encryption:enable; then
-        echo $'Encryption not enabled'
-        exit 73527
+    if [ $NEXTCLOUD_SERVER_SIDE_ENCRYPTION ]; then
+        sudo -u www-data ./occ app:enable encryption
+        if ! sudo -u www-data ./occ encryption:enable; then
+            echo $'Encryption not enabled'
+            exit 73527
+        fi
+        sudo -u www-data ./occ encryption:status
     fi
-    sudo -u www-data ./occ encryption:status
     sudo -u www-data ./occ config:system:set appstoreenabled --value=false
     chmod g+w "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs/config/config.php"
     chown -R www-data:www-data "/var/www/${NEXTCLOUD_DOMAIN_NAME}/htdocs"
-- 
GitLab