From d08993d358b198a281f86088bbfcac5d947870c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jadyn=20Emma=20J=C3=A4ger?= Date: Thu, 1 Aug 2024 19:59:02 +0200 Subject: [PATCH] feat(roles/lego): Add support for LEGO_HTTP_PORT_FALLBACK --- roles/lego/files/lego_run.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/roles/lego/files/lego_run.sh b/roles/lego/files/lego_run.sh index e318eee..a38c965 100644 --- a/roles/lego/files/lego_run.sh +++ b/roles/lego/files/lego_run.sh @@ -3,8 +3,16 @@ LEGO_BINARY=$(/usr/bin/env which lego) FILES_IN_DIR=$(find "$LEGO_CERT_STORE_PATH/certificates" | wc -l) -if [[ $FILES_IN_DIR -gt 2 ]]; then - $LEGO_BINARY $LEGO_COMMAND_ARGS renew --days=$LEGO_CERT_DAYS_TO_RENEW -else - $LEGO_BINARY $LEGO_COMMAND_ARGS run +if [[ -n "$LEGO_HTTP_FALLBACK_PORT" ]]; then + nc -z 127.0.0.1 $LEGO_HTTP_PORT; + if [[ $? -eq 0 ]]; then + LEGO_HTTP_PORT=$LEGO_HTTP_FALLBACK_PORT + fi fi +LEGO_COMMAND_ARGS_EXPANDED=$(bash -c "echo $LEGO_COMMAND_ARGS") # This is a bit icky but +echo $LEGO_COMMAND_ARGS_EXPANDED +if [[ $FILES_IN_DIR -gt 2 ]]; then + $LEGO_BINARY $LEGO_COMMAND_ARGS_EXPANDED renew --days=$LEGO_CERT_DAYS_TO_RENEW +else + $LEGO_BINARY $LEGO_COMMAND_ARGS_EXPANDED run +fi \ No newline at end of file