Skip to content

Commit b9e7d59

Browse files
committed
feat: per-container Pre-Hooks and Post-Hooks
1 parent 312fe57 commit b9e7d59

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

app/letsencrypt_service

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,15 @@ function update_cert {
221221
)
222222

223223
# acme.sh pre and post hooks
224-
if [[ -n "$ACME_PRE_HOOK" ]]; then
225-
params_issue_arr+=(--pre-hook "$ACME_PRE_HOOK")
224+
local -n acme_pre_hook="ACME_${cid}_PRE_HOOK"
225+
acme_pre_hook=${acme_pre_hook:-$ACME_PRE_HOOK}
226+
if [[ -n "${acme_pre_hook// }" ]]; then
227+
params_issue_arr+=(--pre-hook "$acme_pre_hook")
226228
fi
227-
if [[ -n "$ACME_POST_HOOK" ]]; then
228-
params_issue_arr+=(--post-hook "$ACME_POST_HOOK")
229+
local -n acme_post_hook="ACME_${cid}_POST_HOOK"
230+
acme_post_hook=${acme_post_hook:-$ACME_POST_HOOK}
231+
if [[ -n "${acme_post_hook// }" ]]; then
232+
params_issue_arr+=(--post-hook "$acme_post_hook")
229233
fi
230234

231235
[[ ! -d "$config_home" ]] && mkdir -p "$config_home"

app/letsencrypt_service_data.tmpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ LETSENCRYPT_CONTAINERS=(
3131
{{ $EAB_HMAC_KEY := trim (coalesce $container.Env.ACME_EAB_HMAC_KEY "") }}
3232
{{ $ZEROSSL_API_KEY := trim (coalesce $container.Env.ZEROSSL_API_KEY "") }}
3333
{{ $RESTART_CONTAINER := trim (coalesce $container.Env.LETSENCRYPT_RESTART_CONTAINER "") }}
34+
{{ $PRE_HOOK := trim (coalesce $container.Env.ACME_PRE_HOOK "") }}
35+
{{ $POST_HOOK := trim (coalesce $container.Env.ACME_POST_HOOK "") }}
3436
{{ $cid := printf "%.12s" $container.ID }}
3537
{{ if parseBool (coalesce $container.Env.LETSENCRYPT_SINGLE_DOMAIN_CERTS "false") }}
3638
{{/* Explicit per-domain splitting of the certificate */}}
@@ -49,6 +51,8 @@ LETSENCRYPT_CONTAINERS=(
4951
{{- "\n" }}ACME_{{ $cid }}_{{ $hostHash }}_EAB_HMAC_KEY="{{ $EAB_HMAC_KEY }}"
5052
{{- "\n" }}ZEROSSL_{{ $cid }}_{{ $hostHash }}_API_KEY="{{ $ZEROSSL_API_KEY }}"
5153
{{- "\n" }}LETSENCRYPT_{{ $cid }}_{{ $hostHash }}_RESTART_CONTAINER="{{ $RESTART_CONTAINER }}"
54+
{{- "\n" }}ACME_{{ $cid }}_{{ $hostHash }}_PRE_HOOK="{{ $PRE_HOOK }}"
55+
{{- "\n" }}ACME_{{ $cid }}_{{ $hostHash }}_POST_HOOK="{{ $POST_HOOK }}"
5256
{{ end }}
5357
{{ else }}
5458
{{/* Default: multi-domain (SAN) certificate */}}
@@ -69,6 +73,8 @@ LETSENCRYPT_CONTAINERS=(
6973
{{- "\n" }}ACME_{{ $cid }}_EAB_HMAC_KEY="{{ $EAB_HMAC_KEY }}"
7074
{{- "\n" }}ZEROSSL_{{ $cid }}_API_KEY="{{ $ZEROSSL_API_KEY }}"
7175
{{- "\n" }}LETSENCRYPT_{{ $cid }}_RESTART_CONTAINER="{{ $RESTART_CONTAINER }}"
76+
{{- "\n" }}ACME_{{ $cid }}_PRE_HOOK="{{ $PRE_HOOK }}"
77+
{{- "\n" }}ACME_{{ $cid }}_POST_HOOK="{{ $POST_HOOK }}"
7278
{{ end }}
7379
{{ end }}
7480
{{ end }}

0 commit comments

Comments
 (0)