From 27d95554288da12452942eed0209c128c866e5d3 Mon Sep 17 00:00:00 2001 From: transcaffeine Date: Thu, 1 May 2025 13:51:33 +0200 Subject: [PATCH 1/3] fix(lego): do not trigger script abortion on wanted exit code != 0 --- roles/lego/files/lego_run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/lego/files/lego_run.sh b/roles/lego/files/lego_run.sh index 63be0e8..5da78bf 100644 --- a/roles/lego/files/lego_run.sh +++ b/roles/lego/files/lego_run.sh @@ -8,8 +8,8 @@ if [[ -n "${LEGO_HTTP_FALLBACK_PORT:-}" ]]; then echo "nc not found (in PATH), exiting" exit 1 fi - nc -z 127.0.0.1 $LEGO_HTTP_PORT; - if [[ $? -eq 0 ]]; then + nc_exit_code=$(nc -z 127.0.0.1 $LEGO_HTTP_PORT); + if [[ $nc_exit_code -eq 0 ]]; then LEGO_HTTP_PORT=$LEGO_HTTP_FALLBACK_PORT fi fi -- 2.47.2 From e93bb182c0309e29af74e73b476e785ff41854e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jadyn=20Emma=20J=C3=A4ger?= Date: Thu, 1 May 2025 14:16:39 +0200 Subject: [PATCH 2/3] fix: Unset -e during nc command --- roles/lego/files/lego_run.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/lego/files/lego_run.sh b/roles/lego/files/lego_run.sh index 5da78bf..a36c31c 100644 --- a/roles/lego/files/lego_run.sh +++ b/roles/lego/files/lego_run.sh @@ -8,7 +8,9 @@ if [[ -n "${LEGO_HTTP_FALLBACK_PORT:-}" ]]; then echo "nc not found (in PATH), exiting" exit 1 fi + set +e nc_exit_code=$(nc -z 127.0.0.1 $LEGO_HTTP_PORT); + set -e if [[ $nc_exit_code -eq 0 ]]; then LEGO_HTTP_PORT=$LEGO_HTTP_FALLBACK_PORT fi -- 2.47.2 From 9e76d11aa441b6573aaa7c4e908d6f1dcb5c249e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jadyn=20Emma=20J=C3=A4ger?= Date: Sat, 10 May 2025 16:21:12 +0200 Subject: [PATCH 3/3] fix: capture exit code instead of std-out --- roles/lego/files/lego_run.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/roles/lego/files/lego_run.sh b/roles/lego/files/lego_run.sh index a36c31c..2d3e923 100644 --- a/roles/lego/files/lego_run.sh +++ b/roles/lego/files/lego_run.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -euo pipefail +set -xeuo pipefail LEGO_BINARY=$(/usr/bin/env which lego) @@ -9,7 +9,8 @@ if [[ -n "${LEGO_HTTP_FALLBACK_PORT:-}" ]]; then exit 1 fi set +e - nc_exit_code=$(nc -z 127.0.0.1 $LEGO_HTTP_PORT); + nc -z 127.0.0.1 $LEGO_HTTP_PORT; + nc_exit_code=$?; set -e if [[ $nc_exit_code -eq 0 ]]; then LEGO_HTTP_PORT=$LEGO_HTTP_FALLBACK_PORT -- 2.47.2