1
0

feat: per-container Pre-Hooks and Post-Hooks

This commit is contained in:
Nicolas Duchon 2022-03-02 18:42:07 +01:00
parent 312fe57bb8
commit b9e7d59bed
No known key found for this signature in database
GPG Key ID: EA3151C66A4D79E7
2 changed files with 14 additions and 4 deletions

@ -221,11 +221,15 @@ function update_cert {
)
# acme.sh pre and post hooks
if [[ -n "$ACME_PRE_HOOK" ]]; then
params_issue_arr+=(--pre-hook "$ACME_PRE_HOOK")
local -n acme_pre_hook="ACME_${cid}_PRE_HOOK"
acme_pre_hook=${acme_pre_hook:-$ACME_PRE_HOOK}
if [[ -n "${acme_pre_hook// }" ]]; then
params_issue_arr+=(--pre-hook "$acme_pre_hook")
fi
if [[ -n "$ACME_POST_HOOK" ]]; then
params_issue_arr+=(--post-hook "$ACME_POST_HOOK")
local -n acme_post_hook="ACME_${cid}_POST_HOOK"
acme_post_hook=${acme_post_hook:-$ACME_POST_HOOK}
if [[ -n "${acme_post_hook// }" ]]; then
params_issue_arr+=(--post-hook "$acme_post_hook")
fi
[[ ! -d "$config_home" ]] && mkdir -p "$config_home"

@ -31,6 +31,8 @@ LETSENCRYPT_CONTAINERS=(
{{ $EAB_HMAC_KEY := trim (coalesce $container.Env.ACME_EAB_HMAC_KEY "") }}
{{ $ZEROSSL_API_KEY := trim (coalesce $container.Env.ZEROSSL_API_KEY "") }}
{{ $RESTART_CONTAINER := trim (coalesce $container.Env.LETSENCRYPT_RESTART_CONTAINER "") }}
{{ $PRE_HOOK := trim (coalesce $container.Env.ACME_PRE_HOOK "") }}
{{ $POST_HOOK := trim (coalesce $container.Env.ACME_POST_HOOK "") }}
{{ $cid := printf "%.12s" $container.ID }}
{{ if parseBool (coalesce $container.Env.LETSENCRYPT_SINGLE_DOMAIN_CERTS "false") }}
{{/* Explicit per-domain splitting of the certificate */}}
@ -49,6 +51,8 @@ LETSENCRYPT_CONTAINERS=(
{{- "\n" }}ACME_{{ $cid }}_{{ $hostHash }}_EAB_HMAC_KEY="{{ $EAB_HMAC_KEY }}"
{{- "\n" }}ZEROSSL_{{ $cid }}_{{ $hostHash }}_API_KEY="{{ $ZEROSSL_API_KEY }}"
{{- "\n" }}LETSENCRYPT_{{ $cid }}_{{ $hostHash }}_RESTART_CONTAINER="{{ $RESTART_CONTAINER }}"
{{- "\n" }}ACME_{{ $cid }}_{{ $hostHash }}_PRE_HOOK="{{ $PRE_HOOK }}"
{{- "\n" }}ACME_{{ $cid }}_{{ $hostHash }}_POST_HOOK="{{ $POST_HOOK }}"
{{ end }}
{{ else }}
{{/* Default: multi-domain (SAN) certificate */}}
@ -69,6 +73,8 @@ LETSENCRYPT_CONTAINERS=(
{{- "\n" }}ACME_{{ $cid }}_EAB_HMAC_KEY="{{ $EAB_HMAC_KEY }}"
{{- "\n" }}ZEROSSL_{{ $cid }}_API_KEY="{{ $ZEROSSL_API_KEY }}"
{{- "\n" }}LETSENCRYPT_{{ $cid }}_RESTART_CONTAINER="{{ $RESTART_CONTAINER }}"
{{- "\n" }}ACME_{{ $cid }}_PRE_HOOK="{{ $PRE_HOOK }}"
{{- "\n" }}ACME_{{ $cid }}_POST_HOOK="{{ $POST_HOOK }}"
{{ end }}
{{ end }}
{{ end }}