mirror of
https://github.com/dehydrated-io/dehydrated.git
synced 2026-03-17 23:03:47 +01: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
16
dehydrated
16
dehydrated
@@ -1547,6 +1547,20 @@ command_account() {
|
||||
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)
|
||||
# Description: Sign/renew non-existent/changed/expiring certificates.
|
||||
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
|
||||
ORIGIFS="${IFS}"
|
||||
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
|
||||
IFS="${ORIGIFS}"
|
||||
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
|
||||
`*.service.example.com` which can be a useful way to create wildcard
|
||||
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