diff --git a/dappnode_package.json b/dappnode_package.json index 91dcdb0..233ea50 100644 --- a/dappnode_package.json +++ b/dappnode_package.json @@ -24,8 +24,14 @@ { "arg": "UPSTREAM_VERSION", "repo": "nextcloud/server", - "version": "34.0.1" + "version": "34.0.2" } ], - "version": "0.1.1" + "globalEnvs": [ + { + "envs": ["_DAPPNODE_GLOBAL_DOMAIN"], + "services": ["nextcloud"] + } + ], + "version": "0.2.0" } diff --git a/nextcloud/Dockerfile b/nextcloud/Dockerfile index 2de7a04..4f0474f 100644 --- a/nextcloud/Dockerfile +++ b/nextcloud/Dockerfile @@ -22,3 +22,8 @@ RUN { \ } > /usr/src/nextcloud/config/redis.config.php EXPOSE 8034 + +COPY entrypoint.sh /usr/local/bin/entrypoint.sh +RUN chmod +x /usr/local/bin/entrypoint.sh + +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] diff --git a/nextcloud/entrypoint.sh b/nextcloud/entrypoint.sh new file mode 100644 index 0000000..baf6321 --- /dev/null +++ b/nextcloud/entrypoint.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +CONFIG_FILE="/var/www/html/config/config.php" + +if [ -n "${_DAPPNODE_GLOBAL_DOMAIN}" ]; then + if [ -f "${CONFIG_FILE}" ]; then + # Nextcloud already installed -> patch trusted_domains in config.php directly + EXISTING_DOMAINS=$(su -s /bin/bash www-data -c "php occ config:system:get trusted_domains" 2>/dev/null || true) + + if ! printf '%s\n' "${EXISTING_DOMAINS}" | grep -qx "${_DAPPNODE_GLOBAL_DOMAIN}"; then + NEXT_INDEX=$(printf '%s\n' "${EXISTING_DOMAINS}" | grep -c . ) + su -s /bin/bash www-data -c "php occ config:system:set trusted_domains ${NEXT_INDEX} --value=${_DAPPNODE_GLOBAL_DOMAIN}" + fi + else + # First run -> config.php doesn't exist yet, let the official install create it + export NEXTCLOUD_TRUSTED_DOMAINS="${NEXTCLOUD_TRUSTED_DOMAINS:-nextcloud.dappnode} ${_DAPPNODE_GLOBAL_DOMAIN}" + fi +fi + +# Hand off to the official Nextcloud entrypoint +exec /entrypoint.sh apache2-foreground