fix(lego): ensure variables are either defined or have null-check handling

This commit is contained in:
transcaffeine 2025-03-25 17:51:13 +01:00
parent 0aba4024de
commit eb587978c5
Signed by: transcaffeine
GPG Key ID: 03624C433676E465

View File

@ -3,7 +3,7 @@ set -euo pipefail
LEGO_BINARY=$(/usr/bin/env which lego) LEGO_BINARY=$(/usr/bin/env which lego)
if [[ -n "$LEGO_HTTP_FALLBACK_PORT" ]]; then if [[ -n "${LEGO_HTTP_FALLBACK_PORT:-}" ]]; then
if ! nc_binary="$(type -p \"nc\")" || [[ -z $nc_binary ]]; then if ! nc_binary="$(type -p \"nc\")" || [[ -z $nc_binary ]]; then
echo "nc not found (in PATH), exiting" echo "nc not found (in PATH), exiting"
exit 1 exit 1
@ -14,7 +14,7 @@ if [[ -n "$LEGO_HTTP_FALLBACK_PORT" ]]; then
fi fi
fi fi
if [[ -n "$LEGO_PRE_RENEWAL_HOOK" ]]; then if [[ -n "${LEGO_PRE_RENEWAL_HOOK:-}" ]]; then
$LEGO_PRE_RENEWAL_HOOK $LEGO_PRE_RENEWAL_HOOK
fi fi
@ -30,6 +30,6 @@ fi
find "$LEGO_CERT_STORE_PATH/certificates" -type f | xargs -I{} -n 1 chmod "$LEGO_CERT_MODE" "{}" find "$LEGO_CERT_STORE_PATH/certificates" -type f | xargs -I{} -n 1 chmod "$LEGO_CERT_MODE" "{}"
find "$LEGO_CERT_STORE_PATH/certificates" -type f | xargs -I{} -n 1 chown "${LEGO_CERT_USER}:${LEGO_CERT_GROUP}" "{}" find "$LEGO_CERT_STORE_PATH/certificates" -type f | xargs -I{} -n 1 chown "${LEGO_CERT_USER}:${LEGO_CERT_GROUP}" "{}"
if [[ -n "$LEGO_POST_RENEWAL_HOOK" ]]; then if [[ -n "${LEGO_POST_RENEWAL_HOOK:-}" ]]; then
$LEGO_POST_RENEWAL_HOOK $LEGO_POST_RENEWAL_HOOK
fi fi