Skip to content

Commit

Permalink
nextcloud.conf.sh: Allow any user name for metrics endpoint and fix d…
Browse files Browse the repository at this point in the history
…ocker build

Signed-off-by: Tobias K <[email protected]>

nextcloud.conf.sh: Fix apps overwriting each other during templating

Signed-off-by: Tobias K <[email protected]>

nextcloud.conf.sh: Make --default mode failsafe (don't expect apps to be installed)

Signed-off-by: Tobias K <[email protected]>

nextcloud.conf.sh: Allow any user name for metrics endpoint

Signed-off-by: Tobias K <[email protected]>

nextcloudpi/Dockerfile: Copy the templates directory to the container

Signed-off-by: Tobias K <[email protected]>

lamp/Dockerfile: Copy the templates directory to the container

Signed-off-by: Tobias K <[email protected]>

install.sh: Ensure templates are available before executing nc-nextcloud.sh

Signed-off-by: Tobias K <[email protected]>
  • Loading branch information
theCalcaholic authored and nachoparker committed Aug 9, 2021
1 parent b8a990e commit e492032
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 14 deletions.
4 changes: 2 additions & 2 deletions bin/ncp/CONFIG/nc-nextcloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions bin/ncp/NETWORKING/letsencrypt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
1 change: 1 addition & 0 deletions docker/nextcloud/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand Down
29 changes: 19 additions & 10 deletions etc/ncp-templates/nextcloud.conf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 ###"
Expand All @@ -20,9 +31,7 @@ cat <<EOF
DocumentRoot /var/www/nextcloud
EOF

LETSENCRYPT_DOMAIN="$(tmpl_letsencrypt_domain)"
if [[ "$1" != "--defaults" ]] && [[ -n "$LETSENCRYPT_DOMAIN" ]]
then
if [[ "$1" != "--defaults" ]] && [[ -n "$LETSENCRYPT_DOMAIN" ]]; then
echo " ServerName ${LETSENCRYPT_DOMAIN}"
LETSENCRYPT_CERT_BASE_PATH="/etc/letsencrypt/live/${LETSENCRYPT_DOMAIN,,}"
LETSENCRYPT_CERT_PATH="${LETSENCRYPT_CERT_BASE_PATH}/fullchain.pem"
Expand All @@ -41,7 +50,7 @@ cat <<EOF
SSLCertificateKeyFile ${LETSENCRYPT_KEY_PATH:-/etc/ssl/private/ssl-cert-snakeoil.key}
EOF

if [[ "$1" != "--defaults" ]] && tmpl_metrics_enabled
if [[ "$1" != "--defaults" ]] && [[ "$METRICS_IS_ENABLED" == yes ]]
then

cat <<EOF
Expand All @@ -58,7 +67,7 @@ then
<RequireAll>
<RequireAny>
Require host localhost
Require user metrics
Require valid-user
</RequireAny>
</RequireAll>
Expand All @@ -84,4 +93,4 @@ cat <<EOF
</IfModule>
EOF

apache2ctl -t
apache2ctl -t
1 change: 1 addition & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e492032

Please sign in to comment.