Skip to content

Commit

Permalink
Optimise initial ownCloud setup
Browse files Browse the repository at this point in the history
  • Loading branch information
mreid-tt committed Sep 19, 2024
1 parent 6943950 commit 3a49801
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
2 changes: 1 addition & 1 deletion spk/owncloud/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br/>2. Various script fixes and refinements."
CHANGELOG = "1. Update ownCloud to 10.15.0.<br/>2. Various script fixes and refinements.<br/>3. Optimise initial ownCloud setup."
HOMEPAGE = https://owncloud.com/

LICENSE = AGPLv3
Expand Down
23 changes: 17 additions & 6 deletions spk/owncloud/src/service-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 "<IfModule mod_headers.c>"
echo "Header always set Strict-Transport-Security \"max-age=15552000; includeSubDomains\""
echo "</IfModule>"
} >> "${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
}

Expand Down
5 changes: 4 additions & 1 deletion spk/owncloud/src/web/owncloud.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 3a49801

Please sign in to comment.