From 72ecbfec498db2bf15f0e35bd039afd6516fcb8c Mon Sep 17 00:00:00 2001 From: Simon L Date: Mon, 13 Nov 2023 15:53:17 +0100 Subject: [PATCH] re-introduce limiting the php-fpm port to certain containers Signed-off-by: Simon L --- Containers/nextcloud/entrypoint.sh | 10 ++++++-- Containers/nextcloud/start.sh | 41 +++++++++++++++--------------- manual-install/update-yaml.sh | 1 + php/containers.json | 3 ++- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/Containers/nextcloud/entrypoint.sh b/Containers/nextcloud/entrypoint.sh index 534ccada..e7166fac 100644 --- a/Containers/nextcloud/entrypoint.sh +++ b/Containers/nextcloud/entrypoint.sh @@ -491,8 +491,14 @@ else fi # AIO app -if [ "$(php /var/www/html/occ config:app:get nextcloud-aio enabled)" != "yes" ]; then - php /var/www/html/occ app:enable nextcloud-aio +if [ "$THIS_IS_AIO" = "true" ]; then + if [ "$(php /var/www/html/occ config:app:get nextcloud-aio enabled)" != "yes" ]; then + php /var/www/html/occ app:enable nextcloud-aio + fi +else + if [ "$(php /var/www/html/occ config:app:get nextcloud-aio enabled)" != "no" ]; then + php /var/www/html/occ app:disable nextcloud-aio + fi fi # Notify push diff --git a/Containers/nextcloud/start.sh b/Containers/nextcloud/start.sh index 96b82c7e..1e74ea23 100644 --- a/Containers/nextcloud/start.sh +++ b/Containers/nextcloud/start.sh @@ -131,26 +131,25 @@ if ! sudo -E -u www-data bash /entrypoint.sh; then exit 1 fi -# The below was disabled again because it fails on some deployment methods, e.g. on kubernetes -# There is apparently no way to make this work reliably automatically -# while [ -z "$(dig nextcloud-aio-apache A +short +search)" ]; do -# echo "Waiting for nextcloud-aio-apache to start..." -# sleep 5 -# done -# -# set -x -# if [ "$APACHE_PORT" = 443 ] || [ "$APACHE_IP_BINDING" = "127.0.0.1" ] || [ "$APACHE_IP_BINDING" = "::1" ]; then -# IPv4_ADDRESS_APACHE="$(dig nextcloud-aio-apache A +short +search | grep '^[0-9.]\+$' | sort | head -n1)" -# IPv6_ADDRESS_APACHE="$(dig nextcloud-aio-apache AAAA +short +search | grep '^[0-9a-f:]\+$' | sort | head -n1)" -# IPv4_ADDRESS_MASTERCONTAINER="$(dig nextcloud-aio-mastercontainer A +short +search | grep '^[0-9.]\+$' | sort | head -n1)" -# IPv6_ADDRESS_MASTERCONTAINER="$(dig nextcloud-aio-mastercontainer AAAA +short +search | grep '^[0-9a-f:]\+$' | sort | head -n1)" -# -# sed -i "s|^;listen.allowed_clients|listen.allowed_clients|" /usr/local/etc/php-fpm.d/www.conf -# sed -i "s|listen.allowed_clients.*|listen.allowed_clients = 127.0.0.1,::1,$IPv4_ADDRESS_APACHE,$IPv6_ADDRESS_APACHE,$IPv4_ADDRESS_MASTERCONTAINER,$IPv6_ADDRESS_MASTERCONTAINER|" /usr/local/etc/php-fpm.d/www.conf -# sed -i "/^listen.allowed_clients/s/,,/,/g" /usr/local/etc/php-fpm.d/www.conf -# sed -i "/^listen.allowed_clients/s/,$//" /usr/local/etc/php-fpm.d/www.conf -# grep listen.allowed_clients /usr/local/etc/php-fpm.d/www.conf -# fi -# set +x +while [ "$THIS_IS_AIO" = "true" ] && [ -z "$(dig nextcloud-aio-apache A +short +search)" ]; do + echo "Waiting for nextcloud-aio-apache to start..." + sleep 5 +done + +set -x +# shellcheck disable=SC2235 +if [ "$THIS_IS_AIO" = "true" ] && ([ "$APACHE_PORT" = 443 ] || [ "$APACHE_IP_BINDING" = "127.0.0.1" ] || [ "$APACHE_IP_BINDING" = "::1" ]); then + IPv4_ADDRESS_APACHE="$(dig nextcloud-aio-apache A +short +search | grep '^[0-9.]\+$' | sort | head -n1)" + IPv6_ADDRESS_APACHE="$(dig nextcloud-aio-apache AAAA +short +search | grep '^[0-9a-f:]\+$' | sort | head -n1)" + IPv4_ADDRESS_MASTERCONTAINER="$(dig nextcloud-aio-mastercontainer A +short +search | grep '^[0-9.]\+$' | sort | head -n1)" + IPv6_ADDRESS_MASTERCONTAINER="$(dig nextcloud-aio-mastercontainer AAAA +short +search | grep '^[0-9a-f:]\+$' | sort | head -n1)" + + sed -i "s|^;listen.allowed_clients|listen.allowed_clients|" /usr/local/etc/php-fpm.d/www.conf + sed -i "s|listen.allowed_clients.*|listen.allowed_clients = 127.0.0.1,::1,$IPv4_ADDRESS_APACHE,$IPv6_ADDRESS_APACHE,$IPv4_ADDRESS_MASTERCONTAINER,$IPv6_ADDRESS_MASTERCONTAINER|" /usr/local/etc/php-fpm.d/www.conf + sed -i "/^listen.allowed_clients/s/,,/,/g" /usr/local/etc/php-fpm.d/www.conf + sed -i "/^listen.allowed_clients/s/,$//" /usr/local/etc/php-fpm.d/www.conf + grep listen.allowed_clients /usr/local/etc/php-fpm.d/www.conf +fi +set +x exec "$@" diff --git a/manual-install/update-yaml.sh b/manual-install/update-yaml.sh index df066696..865c2376 100644 --- a/manual-install/update-yaml.sh +++ b/manual-install/update-yaml.sh @@ -32,6 +32,7 @@ echo "$OUTPUT" | yq -P > ./manual-install/containers.yml cd manual-install || exit sed -i "s|'||g" containers.yml sed -i '/display_name:/d' containers.yml +sed -i '/THIS_IS_AIO:/d' containers.yml sed -i '/stop_grace_period:/s/$/s/' containers.yml sed -i '/: \[\]/d' containers.yml sed -i 's|- source: |- |' containers.yml diff --git a/php/containers.json b/php/containers.json index c75ffab1..e52c61fa 100644 --- a/php/containers.json +++ b/php/containers.json @@ -212,7 +212,8 @@ "DOCKER_SOCKET_PROXY_ENABLED=%DOCKER_SOCKET_PROXY_ENABLED%", "REMOVE_DISABLED_APPS=%REMOVE_DISABLED_APPS%", "APACHE_PORT=%APACHE_PORT%", - "APACHE_IP_BINDING=%APACHE_IP_BINDING%" + "APACHE_IP_BINDING=%APACHE_IP_BINDING%", + "THIS_IS_AIO=true" ], "restart": "unless-stopped", "devices": [