From e49203249b8842e3586c7893ab59fd1bf779da20 Mon Sep 17 00:00:00 2001 From: Tobias K <6317548+theCalcaholic@users.noreply.github.com> Date: Mon, 2 Aug 2021 23:49:40 +0200 Subject: nextcloud.conf.sh: Allow any user name for metrics endpoint and fix docker build Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com> nextcloud.conf.sh: Fix apps overwriting each other during templating Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com> nextcloud.conf.sh: Make --default mode failsafe (don't expect apps to be installed) Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com> nextcloud.conf.sh: Allow any user name for metrics endpoint Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com> nextcloudpi/Dockerfile: Copy the templates directory to the container Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com> lamp/Dockerfile: Copy the templates directory to the container Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com> install.sh: Ensure templates are available before executing nc-nextcloud.sh Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com> --- bin/ncp/CONFIG/nc-nextcloud.sh | 4 ++-- bin/ncp/NETWORKING/letsencrypt.sh | 3 +-- docker/nextcloud/Dockerfile | 1 + etc/ncp-templates/nextcloud.conf.sh | 29 +++++++++++++++++++---------- install.sh | 1 + 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/bin/ncp/CONFIG/nc-nextcloud.sh b/bin/ncp/CONFIG/nc-nextcloud.sh index fa522a57..f9e2c0c1 100644 --- a/bin/ncp/CONFIG/nc-nextcloud.sh +++ b/bin/ncp/CONFIG/nc-nextcloud.sh @@ -175,9 +175,9 @@ EOF ## SET APACHE VHOST echo "Setting up Apache..." - bash /usr/local/etc/nextcloud.conf.sh > /etc/apache2/sites-available/nextcloud.conf || { + bash /usr/local/etc/ncp-templates/nextcloud.conf.sh > /etc/apache2/sites-available/nextcloud.conf || { echo "ERROR: An error occured while generating the nextcloud apache2 config. Attempting safe mode..." - bash /usr/local/etc/nextcloud.conf.sh --defaults > /etc/apache2/sites-available/nextcloud.conf || { + bash /usr/local/etc/ncp-templates/nextcloud.conf.sh --defaults > /etc/apache2/sites-available/nextcloud.conf || { echo "ERROR: Safe mode templating failed as well. Nextcloud will not work." exit 1 } diff --git a/bin/ncp/NETWORKING/letsencrypt.sh b/bin/ncp/NETWORKING/letsencrypt.sh index 9b5df324..c40a4fa9 100644 --- a/bin/ncp/NETWORKING/letsencrypt.sh +++ b/bin/ncp/NETWORKING/letsencrypt.sh @@ -21,8 +21,7 @@ is_active() tmpl_letsencrypt_domain() { ( . /usr/local/etc/library.sh - if is_active - then + if is_active; then find_app_param letsencrypt DOMAIN fi ) diff --git a/docker/nextcloud/Dockerfile b/docker/nextcloud/Dockerfile index 225fef13..e3918122 100644 --- a/docker/nextcloud/Dockerfile +++ b/docker/nextcloud/Dockerfile @@ -13,6 +13,7 @@ ENV DOCKERBUILD 1 COPY etc/library.sh /usr/local/etc/ COPY bin/ncp/CONFIG/nc-nextcloud.sh / COPY etc/ncp-config.d/nc-nextcloud.cfg /usr/local/etc/ncp-config.d/ +COPY etc/ncp-templates /usr/local/etc/ncp-templates RUN --mount=type=cache,target=/var/cache/apt --mount=type=cache,target=/var/lib/apt \ set -e; \ diff --git a/etc/ncp-templates/nextcloud.conf.sh b/etc/ncp-templates/nextcloud.conf.sh index 93420f79..a3c4e8c1 100644 --- a/etc/ncp-templates/nextcloud.conf.sh +++ b/etc/ncp-templates/nextcloud.conf.sh @@ -2,13 +2,24 @@ set -e source /usr/local/etc/library.sh -source "${BINDIR}/NETWORKING/letsencrypt.sh" -if [[ "$DOCKERBUILD" == 1 ]] -then +if [[ "$1" != "--defaults" ]]; then + LETSENCRYPT_DOMAIN="$( + # force defaults during initial build + if ! [[ -f /.ncp-image ]]; then + source "${BINDIR}/NETWORKING/letsencrypt.sh" + tmpl_letsencrypt_domain + fi + )" +fi + +if [[ "$DOCKERBUILD" != 1 ]] && [[ "$1" != "--defaults" ]]; then + METRICS_IS_ENABLED="$( source "${BINDIR}/SYSTEM/metrics.sh" + tmpl_metrics_enabled && echo yes || echo no + )" else - tmpl_metrics_enabled(){ return 1; } + METRICS_IS_ENABLED=no fi echo "### DO NOT EDIT! THIS FILE HAS BEEN AUTOMATICALLY GENERATED. CHANGES WILL BE OVERWRITTEN ###" @@ -20,9 +31,7 @@ cat < Require host localhost - Require user metrics + Require valid-user @@ -84,4 +93,4 @@ cat < EOF -apache2ctl -t \ No newline at end of file +apache2ctl -t diff --git a/install.sh b/install.sh index bf83c2ba..4217972d 100644 --- a/install.sh +++ b/install.sh @@ -54,6 +54,7 @@ cp etc/ncp-config.d/nc-nextcloud.cfg /usr/local/etc/ncp-config.d/ cp etc/library.sh /usr/local/etc/ cp etc/ncp.cfg /usr/local/etc/ +cp -r etc/ncp-templates /usr/local/etc/ install_app lamp.sh install_app bin/ncp/CONFIG/nc-nextcloud.sh run_app_unsafe bin/ncp/CONFIG/nc-nextcloud.sh -- cgit v1.2.3