From a993ca0fc589b21a7679cd53772f125c6894dbbe Mon Sep 17 00:00:00 2001 From: JMarcosHP Date: Mon, 9 Dec 2024 19:26:12 -0600 Subject: [PATCH 1/4] Added domain reachability check and retry mechanism to run-exec-commands.sh Signed-off-by: JMarcosHP --- Containers/nextcloud/run-exec-commands.sh | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Containers/nextcloud/run-exec-commands.sh b/Containers/nextcloud/run-exec-commands.sh index ab3abab7171..a9bce829bf8 100644 --- a/Containers/nextcloud/run-exec-commands.sh +++ b/Containers/nextcloud/run-exec-commands.sh @@ -1,7 +1,24 @@ #!/bin/bash -# Wait 15s for domain to be reachable +# ENV Variables +MAX_RETRY=3 +COUNT=3 + +# Wait until the domain is reachable sleep 15 +while [ $COUNT -le $MAX_RETRY ]; do + if nc -z $NC_DOMAIN 443; then + echo "Domain reached." + break + else + echo "Attempt $COUNT: Domain not reachable. Retrying in 15 seconds..." + sleep 15 + ((COUNT++)) + fi +done +if [ $COUNT -gt $MAX_RETRY ]; then + echo "The domain could not be reached after $MAX_RETRY attempts. Proceeding anyway..." +fi if [ -n "$NEXTCLOUD_EXEC_COMMANDS" ]; then echo "#!/bin/bash" > /tmp/nextcloud-exec-commands From 997886054d0a48813f19e22cbcfcad12138a1bdc Mon Sep 17 00:00:00 2001 From: Jehu Marcos Herrera Puentes <58377032+JMarcosHP@users.noreply.github.com> Date: Mon, 9 Dec 2024 19:29:16 -0600 Subject: [PATCH 2/4] Set $COUNT variable to 1 Signed-off-by: Jehu Marcos Herrera Puentes <58377032+JMarcosHP@users.noreply.github.com> --- Containers/nextcloud/run-exec-commands.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Containers/nextcloud/run-exec-commands.sh b/Containers/nextcloud/run-exec-commands.sh index a9bce829bf8..de674b9baaf 100644 --- a/Containers/nextcloud/run-exec-commands.sh +++ b/Containers/nextcloud/run-exec-commands.sh @@ -2,7 +2,7 @@ # ENV Variables MAX_RETRY=3 -COUNT=3 +COUNT=1 # Wait until the domain is reachable sleep 15 From 5f844aeeb13b77e11660dcc2d217fbaa451207f3 Mon Sep 17 00:00:00 2001 From: Jehu Marcos Herrera Puentes <58377032+JMarcosHP@users.noreply.github.com> Date: Mon, 16 Dec 2024 11:26:03 -0600 Subject: [PATCH 3/4] Fix shell check variable quotation. Signed-off-by: Jehu Marcos Herrera Puentes <58377032+JMarcosHP@users.noreply.github.com> --- Containers/nextcloud/run-exec-commands.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Containers/nextcloud/run-exec-commands.sh b/Containers/nextcloud/run-exec-commands.sh index de674b9baaf..d98527f9cc0 100644 --- a/Containers/nextcloud/run-exec-commands.sh +++ b/Containers/nextcloud/run-exec-commands.sh @@ -6,8 +6,8 @@ COUNT=1 # Wait until the domain is reachable sleep 15 -while [ $COUNT -le $MAX_RETRY ]; do - if nc -z $NC_DOMAIN 443; then +while [ "$COUNT" -le "$MAX_RETRY" ]; do + if nc -z "$NC_DOMAIN" 443; then echo "Domain reached." break else @@ -16,7 +16,7 @@ while [ $COUNT -le $MAX_RETRY ]; do ((COUNT++)) fi done -if [ $COUNT -gt $MAX_RETRY ]; then +if [ "$COUNT" -gt "$MAX_RETRY" ]; then echo "The domain could not be reached after $MAX_RETRY attempts. Proceeding anyway..." fi From 3c2a1edcc4f491539fffd969d726f9a6b0d5ec2a Mon Sep 17 00:00:00 2001 From: JMarcosHP Date: Tue, 17 Dec 2024 10:39:01 -0600 Subject: [PATCH 4/4] Added env variable to nextcloud container, changed reachability in favor of apache container host. Signed-off-by: JMarcosHP --- Containers/nextcloud/run-exec-commands.sh | 22 ++++------------------ manual-install/latest.yml | 3 ++- php/containers.json | 3 ++- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/Containers/nextcloud/run-exec-commands.sh b/Containers/nextcloud/run-exec-commands.sh index d98527f9cc0..e917a96d0d6 100644 --- a/Containers/nextcloud/run-exec-commands.sh +++ b/Containers/nextcloud/run-exec-commands.sh @@ -1,24 +1,10 @@ #!/bin/bash -# ENV Variables -MAX_RETRY=3 -COUNT=1 - -# Wait until the domain is reachable -sleep 15 -while [ "$COUNT" -le "$MAX_RETRY" ]; do - if nc -z "$NC_DOMAIN" 443; then - echo "Domain reached." - break - else - echo "Attempt $COUNT: Domain not reachable. Retrying in 15 seconds..." - sleep 15 - ((COUNT++)) - fi +# Wait until the apache container is ready +while ! nc -z "$APACHE_HOST" "$APACHE_PORT"; do + echo "Waiting for Apache to become available..." + sleep 15 done -if [ "$COUNT" -gt "$MAX_RETRY" ]; then - echo "The domain could not be reached after $MAX_RETRY attempts. Proceeding anyway..." -fi if [ -n "$NEXTCLOUD_EXEC_COMMANDS" ]; then echo "#!/bin/bash" > /tmp/nextcloud-exec-commands diff --git a/manual-install/latest.yml b/manual-install/latest.yml index 15af7f53cfb..049c5d11fd1 100644 --- a/manual-install/latest.yml +++ b/manual-install/latest.yml @@ -136,6 +136,8 @@ services: - POSTGRES_USER=nextcloud - REDIS_HOST=nextcloud-aio-redis - REDIS_HOST_PASSWORD=${REDIS_PASSWORD} + - APACHE_HOST=nextcloud-aio-apache + - APACHE_PORT - NC_DOMAIN - ADMIN_USER=admin - ADMIN_PASSWORD=${NEXTCLOUD_PASSWORD} @@ -174,7 +176,6 @@ services: - TALK_RECORDING_HOST=nextcloud-aio-talk-recording - FULLTEXTSEARCH_PASSWORD - REMOVE_DISABLED_APPS - - APACHE_PORT - IMAGINARY_SECRET - WHITEBOARD_SECRET - WHITEBOARD_ENABLED diff --git a/php/containers.json b/php/containers.json index a65530391f3..1b0192b6cc4 100644 --- a/php/containers.json +++ b/php/containers.json @@ -210,6 +210,8 @@ "POSTGRES_USER=nextcloud", "REDIS_HOST=nextcloud-aio-redis", "REDIS_HOST_PASSWORD=%REDIS_PASSWORD%", + "APACHE_HOST=nextcloud-aio-apache", + "APACHE_PORT=%APACHE_PORT%", "AIO_TOKEN=%AIO_TOKEN%", "NC_DOMAIN=%NC_DOMAIN%", "ADMIN_USER=admin", @@ -251,7 +253,6 @@ "FULLTEXTSEARCH_PASSWORD=%FULLTEXTSEARCH_PASSWORD%", "DOCKER_SOCKET_PROXY_ENABLED=%DOCKER_SOCKET_PROXY_ENABLED%", "REMOVE_DISABLED_APPS=%REMOVE_DISABLED_APPS%", - "APACHE_PORT=%APACHE_PORT%", "ADDITIONAL_TRUSTED_PROXY=%CADDY_IP_ADDRESS%", "THIS_IS_AIO=true", "IMAGINARY_SECRET=%IMAGINARY_SECRET%",