mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-07-09 22:52:40 +02:00
Support reading domains from drop-in snippets in domains.txt.d
This commit is contained in:
committed by
Lukas Schauer
parent
e963438c5a
commit
f6a84a88fa
+15
-1
@@ -1547,6 +1547,20 @@ command_account() {
|
|||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Parse contents of domains.txt and domains.txt.d
|
||||||
|
parse_domains_txt() {
|
||||||
|
# Allow globbing temporarily
|
||||||
|
[[ -n "${ZSH_VERSION:-}" ]] && set +o noglob || set +f
|
||||||
|
local inputs=("${DOMAINS_TXT}" "${DOMAINS_TXT}.d"/*.txt)
|
||||||
|
[[ -n "${ZSH_VERSION:-}" ]] && set -o noglob || set -f
|
||||||
|
|
||||||
|
cat "${inputs[@]}" |
|
||||||
|
tr -d '\r' |
|
||||||
|
awk '{print tolower($0)}' |
|
||||||
|
_sed -e 's/^[[:space:]]*//g' -e 's/[[:space:]]*$//g' -e 's/[[:space:]]+/ /g' -e 's/([^ ])>/\1 >/g' -e 's/> />/g' |
|
||||||
|
(grep -vE '^(#|$)' || true)
|
||||||
|
}
|
||||||
|
|
||||||
# Usage: --cron (-c)
|
# Usage: --cron (-c)
|
||||||
# Description: Sign/renew non-existent/changed/expiring certificates.
|
# Description: Sign/renew non-existent/changed/expiring certificates.
|
||||||
command_sign_domains() {
|
command_sign_domains() {
|
||||||
@@ -1579,7 +1593,7 @@ command_sign_domains() {
|
|||||||
# Generate certificates for all domains found in domains.txt. Check if existing certificate are about to expire
|
# Generate certificates for all domains found in domains.txt. Check if existing certificate are about to expire
|
||||||
ORIGIFS="${IFS}"
|
ORIGIFS="${IFS}"
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for line in $(<"${DOMAINS_TXT}" tr -d '\r' | awk '{print tolower($0)}' | _sed -e 's/^[[:space:]]*//g' -e 's/[[:space:]]*$//g' -e 's/[[:space:]]+/ /g' -e 's/([^ ])>/\1 >/g' -e 's/> />/g' | (grep -vE '^(#|$)' || true)); do
|
for line in $(parse_domains_txt); do
|
||||||
reset_configvars
|
reset_configvars
|
||||||
IFS="${ORIGIFS}"
|
IFS="${ORIGIFS}"
|
||||||
alias="$(grep -Eo '>[^ ]+' <<< "${line}" || true)"
|
alias="$(grep -Eo '>[^ ]+' <<< "${line}" || true)"
|
||||||
|
|||||||
@@ -94,3 +94,10 @@ This creates two certificates one for `service.example.com` with an
|
|||||||
**Note:** The first certificate is valid for both `service.example.com` and for
|
**Note:** The first certificate is valid for both `service.example.com` and for
|
||||||
`*.service.example.com` which can be a useful way to create wildcard
|
`*.service.example.com` which can be a useful way to create wildcard
|
||||||
certificates.
|
certificates.
|
||||||
|
|
||||||
|
### Drop-in directory
|
||||||
|
|
||||||
|
If a directory named `domains.txt.d` exists in the same location as
|
||||||
|
`domains.txt`, the contents of `*.txt` files in that directory are appended to
|
||||||
|
the list of domains, in alphabetical order of the filenames. This is useful for
|
||||||
|
automation, as it doesn't require editing an existing file to add new domains.
|
||||||
|
|||||||
Reference in New Issue
Block a user