1+ #! /bin/bash
2+ # shellcheck disable=SC2034
13LETSENCRYPT_CONTAINERS=(
2- {{ range $hosts, $containers := groupBy $ "Env.LETSENCRYPT_HOST" }}
3- {{ if trim $hosts }}
4- {{ range $container := $containers }}
5- {{ if parseBool (coalesce $container.Env.LETSENCRYPT_SINGLE_DOMAIN_CERTS "false") }}
6- {{/* Explicit per-domain splitting of the certificate */}}
7- {{ range $host := split $hosts "," }}
8- {{ $host := trim $host }}
9- {{- "\t"}}'{{ printf "%.12s" $container.ID }}_{{ sha1 $host }}'
10- {{ end }}
11- {{ else }}
12- {{/* Default: multi-domain (SAN) certificate */}}
13- {{- "\t"}}'{{ printf "%.12s" $container.ID }}'
14- {{ end }}
4+ {{ $orderedContainers := sortObjectsByKeysDesc $ " Created" }}
5+ {{ range $_ , $container := whereExist $orderedContainers " Env.LETSENCRYPT_HOST" }}
6+ {{ if trim $container .Env.LETSENCRYPT_HOST }}
7+ {{ if parseBool (coalesce $container .Env.LETSENCRYPT_SINGLE_DOMAIN_CERTS " false" ) }}
8+ {{/* Explicit per-domain splitting of the certificate * /}}
9+ {{ range $host := split $container .Env.LETSENCRYPT_HOST " ," }}
10+ {{ $host := trim $host }}
11+ {{- " \n " }}' {{ printf "%.12s" $container.ID }}_{{ sha1 $host }}' # {{ $container.Name }}, created at {{ $container.Created }}
1512 {{ end }}
13+ {{ else }}
14+ {{/* Default: multi-domain (SAN) certificate * /}}
15+ {{- " \n " }}' {{ printf "%.12s" $container.ID }}' # {{ $container.Name }}, created at {{ $container.Created }}
1616 {{ end }}
1717 {{ end }}
18+ {{ end }}
1819)
1920
2021{{ range $hosts , $containers := groupBy $ " Env.LETSENCRYPT_HOST" }}
@@ -34,6 +35,7 @@ LETSENCRYPT_CONTAINERS=(
3435 {{ $PRE_HOOK := trim (coalesce $container .Env.ACME_PRE_HOOK " " ) }}
3536 {{ $POST_HOOK := trim (coalesce $container .Env.ACME_POST_HOOK " " ) }}
3637 {{ $cid := printf " %.12s" $container .ID }}
38+ {{- " \n" }}# Container {{ $cid }} ({{ $container.Name }})
3739 {{ if parseBool (coalesce $container .Env.LETSENCRYPT_SINGLE_DOMAIN_CERTS " false" ) }}
3840 {{/* Explicit per-domain splitting of the certificate * /}}
3941 {{ range $host := split $hosts " ," }}
0 commit comments