From 1f6b8d48a90c4c67906af5b42162dba1772a74b6 Mon Sep 17 00:00:00 2001 From: szaimen Date: Sun, 29 May 2022 16:25:00 +0200 Subject: [PATCH] fix writing to the caddyfile Signed-off-by: szaimen --- Containers/apache/Dockerfile | 3 +-- Containers/apache/start.sh | 6 ++++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Containers/apache/Dockerfile b/Containers/apache/Dockerfile index 1d94bf35..bce060bf 100644 --- a/Containers/apache/Dockerfile +++ b/Containers/apache/Dockerfile @@ -65,8 +65,7 @@ COPY start.sh /usr/bin/ COPY supervisord.conf / RUN chmod +x /usr/bin/start.sh; \ chmod +r /supervisord.conf; \ - chmod a+w /Caddyfile; \ - chmod 777 /; \ + chown www-data:www-data /Caddyfile; \ chmod +r -R /etc/apache2 # Give root a random password diff --git a/Containers/apache/start.sh b/Containers/apache/start.sh index f32e617f..bdbb91c1 100644 --- a/Containers/apache/start.sh +++ b/Containers/apache/start.sh @@ -21,14 +21,16 @@ if [ -z "$APACHE_PORT" ]; then export APACHE_PORT="443" fi +# Change the Caddyfile if [ "$APACHE_PORT" != '443' ]; then export PROTOCOL="http" export NC_DOMAIN="" - sed -i 's|auto_https.*|auto_https off|' /Caddyfile + CADDYFILE="$(sed 's|auto_https.*|auto_https off|' /Caddyfile)" else export PROTOCOL="https" - sed -i 's|auto_https.*|auto_https disable_redirects|' /Caddyfile + CADDYFILE="$(sed 's|auto_https.*|auto_https disable_redirects|' /Caddyfile)" fi +echo "$CADDYFILE" > /Caddyfile # Add caddy path mkdir -p /mnt/data/caddy/