2024-05-19 18:40:43 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
LEGO_BINARY=$(/usr/bin/env which lego)
|
|
|
|
|
2024-08-01 17:59:02 +00:00
|
|
|
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
|
|
|
|
|
2024-05-19 18:40:43 +00:00
|
|
|
FILES_IN_DIR=$(find "$LEGO_CERT_STORE_PATH/certificates" | wc -l)
|
|
|
|
if [[ $FILES_IN_DIR -gt 2 ]]; then
|
2024-08-01 17:59:02 +00:00
|
|
|
$LEGO_BINARY $LEGO_COMMAND_ARGS_EXPANDED renew --days=$LEGO_CERT_DAYS_TO_RENEW
|
2024-05-19 18:40:43 +00:00
|
|
|
else
|
2024-08-01 17:59:02 +00:00
|
|
|
$LEGO_BINARY $LEGO_COMMAND_ARGS_EXPANDED run
|
2024-09-11 15:47:49 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
ls "$LEGO_CERT_STORE_PATH/certificates" | xargs -I{} -n 1 chmod "$LEGO_CERT_MODE" "$LEGO_CERT_STORE_PATH/certificates/{}"
|
|
|
|
ls "$LEGO_CERT_STORE_PATH/certificates" | xargs -I{} -n 1 chown "$LEGO_CERT_USER":"$LEGO_CERT_GROUP" "$LEGO_CERT_STORE_PATH/certificates/{}"
|