From 3a49801aa0233ca11a7d1582c54eb96d78b31a82 Mon Sep 17 00:00:00 2001 From: mreid-tt <943378+mreid-tt@users.noreply.github.com> Date: Thu, 19 Sep 2024 09:06:02 -0400 Subject: [PATCH] Optimise initial ownCloud setup --- spk/owncloud/Makefile | 2 +- spk/owncloud/src/service-setup.sh | 23 +++++++++++++++++------ spk/owncloud/src/web/owncloud.json | 5 ++++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/spk/owncloud/Makefile b/spk/owncloud/Makefile index c77e148fc091..bb79b46e0b79 100644 --- a/spk/owncloud/Makefile +++ b/spk/owncloud/Makefile @@ -13,7 +13,7 @@ SPK_DEPENDS = WebStation:PHP7.4:Apache2.4 MAINTAINER = SynoCommunity DESCRIPTION = ownCloud is a personal cloud which runs on your own server and gives you freedom and control over your own data. DISPLAY_NAME = ownCloud -CHANGELOG = "1. Update ownCloud to 10.15.0.
2. Various script fixes and refinements." +CHANGELOG = "1. Update ownCloud to 10.15.0.
2. Various script fixes and refinements.
3. Optimise initial ownCloud setup." HOMEPAGE = https://owncloud.com/ LICENSE = AGPLv3 diff --git a/spk/owncloud/src/service-setup.sh b/spk/owncloud/src/service-setup.sh index a1de5924849d..70ff46aa0145 100755 --- a/spk/owncloud/src/service-setup.sh +++ b/spk/owncloud/src/service-setup.sh @@ -55,7 +55,9 @@ exec_occ() { OCC="${WEB_ROOT}/occ" COMMAND="${PHP} ${OCC} $*" if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then - /bin/su "$WEB_USER" -s /bin/sh -c "$COMMAND" + # Escape backslashes for DSM 6 + ESCAPED_COMMAND=$(echo "$COMMAND" | sed 's/\\/\\\\/g') + /bin/su "$WEB_USER" -s /bin/sh -c "$ESCAPED_COMMAND" else $COMMAND fi @@ -67,7 +69,9 @@ exec_eff_occ() { OCC="${WEB_ROOT}/occ" COMMAND="${PHP} ${OCC} $*" if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then - /bin/su "$EFF_USER" -s /bin/sh -c "$COMMAND" + # Escape backslashes for DSM 6 + ESCAPED_COMMAND=$(echo "$COMMAND" | sed 's/\\/\\\\/g') + /bin/su "$EFF_USER" -s /bin/sh -c "$ESCAPED_COMMAND" else $COMMAND fi @@ -137,15 +141,22 @@ setup_owncloud_instance() fi done - # Add HTTP to HTTPS redirect to Apache configuration file + # Enable HTTP Strict Transport Security in Apache configuration file APACHE_CONF="${WEB_ROOT}/.htaccess" if [ -f "${APACHE_CONF}" ]; then { - echo "RewriteEngine On" - echo "RewriteCond %{HTTPS} off" - echo "RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]" + echo "" + echo "Header always set Strict-Transport-Security \"max-age=15552000; includeSubDomains\"" + echo "" } >> "${APACHE_CONF}" fi + + # Configure background jobs using cron + exec_occ system:cron + + # Configure memory caching + MEMCACHE_VAL="\\OC\\Memcache\\APCu" + exec_occ config:system:set memcache.local --value="$MEMCACHE_VAL" fi } diff --git a/spk/owncloud/src/web/owncloud.json b/spk/owncloud/src/web/owncloud.json index 1e4c29111dc3..b67025f8451a 100644 --- a/spk/owncloud/src/web/owncloud.json +++ b/spk/owncloud/src/web/owncloud.json @@ -30,7 +30,10 @@ "start_servers": 2 }, "open_basedir": "", - "php_settings": {}, + "php_settings": { + "error_log": "/var/services/web/owncloud/php_errors.log", + "max_execution_time": "900" + }, "profile_desc": "PHP Profile for ownCloud", "profile_name": "ownCloud Profile" }