diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-12-31 09:20:25 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2021-12-31 09:20:25 +0000 |
commit | 0b5944bfd61cac36c40079493f25a83c60851503 (patch) | |
tree | e22f232b8e74ed7e6259b82f2478a0c6f86df409 /dehydrated/bin | |
parent | Adding upstream version 20211213. (diff) | |
download | open-infrastructure-service-tools-0b5944bfd61cac36c40079493f25a83c60851503.tar.xz open-infrastructure-service-tools-0b5944bfd61cac36c40079493f25a83c60851503.zip |
Adding upstream version 20211231.upstream/20211231
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dehydrated/bin')
-rwxr-xr-x | dehydrated/bin/dehydrated-cron | 4 | ||||
-rwxr-xr-x | dehydrated/bin/dehydrated-nsupdate | 44 |
2 files changed, 43 insertions, 5 deletions
diff --git a/dehydrated/bin/dehydrated-cron b/dehydrated/bin/dehydrated-cron index 8e7904c..62bbfd7 100755 --- a/dehydrated/bin/dehydrated-cron +++ b/dehydrated/bin/dehydrated-cron @@ -23,7 +23,7 @@ set -e mkdir -p /var/log/dehydrated -dehydrated -c >> /var/log/dehydrated/dehydrated.log -dehydrated -gcd >> /var/log/dehydrated/dehydrated.log +dehydrated --cron --keep-going >> /var/log/dehydrated/dehydrated.log +dehydrated --cleanup-delete >> /var/log/dehydrated/dehydrated.log chown -R root:adm /var/log/dehydrated diff --git a/dehydrated/bin/dehydrated-nsupdate b/dehydrated/bin/dehydrated-nsupdate index be773f8..0b93145 100755 --- a/dehydrated/bin/dehydrated-nsupdate +++ b/dehydrated/bin/dehydrated-nsupdate @@ -46,6 +46,19 @@ if command -v kdig > /dev/null 2>&1 then # knot-dnsutils DIG="kdig +noidn" + + # out-of-tree json output support + if kdig +json > /dev/null 2>&1 + then + DIG="${DIG} +json" + KDIG_JSON="true" + + if ! command -v jq > /dev/null 2>&1 + then + echo "'${HOOK}': need jq for knot-dnsutils with json output" >&2 + exit 1 + fi + fi elif command -v dig > /dev/null 2>&1 then # bind-dnsutils @@ -79,7 +92,15 @@ do done # find txt record to update -CNAME="$(${DIG} +nocomments +noquestion "_acme-challenge.${DOMAIN}" 2>&1 | grep -v '^;' | awk '/CNAME/ { print $5 }' | tail -n1)" +case "${KDIG_JSON}" in + true) + CNAME="$(${DIG} "_acme-challenge.${DOMAIN}" | jq -r -M '.answer | .[] | .rdata' | tail -n1)" + ;; + + *) + CNAME="$(${DIG} +nocomments +noquestion "_acme-challenge.${DOMAIN}" 2>&1 | grep -v '^;' | awk '/CNAME/ { print $5 }' | tail -n1)" + ;; +esac if [ -n "${CNAME}" ] then @@ -93,11 +114,28 @@ ZONE="${TXT_RECORD}" while true do - NAMESERVERS="$(${DIG} +nocomments +noquestion NS "${ZONE}" 2>&1 | grep -v '^;' | awk '/NS/ { print $5 }')" + case "${KDIG_JSON}" in + true) + NAMESERVERS="$(${DIG} NS "${ZONE}" | jq -r -M '.answer | .[] | .rdata')" + ;; + + *) + NAMESERVERS="$(${DIG} +nocomments +noquestion NS "${ZONE}" 2>&1 | grep -v '^;' | awk '/NS/ { print $5 }')" + ;; + esac if [ -n "${NAMESERVERS}" ] then - ZONE="$(${DIG} +nocomments +noquestion NS "${ZONE}" 2>&1 | grep -v '^;' | awk '/NS/ { print $1 }' | tail -n1)" + case "${KDIG_JSON}" in + true) + ZONE="$(${DIG} NS "${ZONE}" | jq -r -M '.answer | .[] | .rdata' | tail -n1)" + ;; + + *) + ZONE="$(${DIG} +nocomments +noquestion NS "${ZONE}" 2>&1 | grep -v '^;' | awk '/NS/ { print $1 }' | tail -n1)" + ;; + esac + break else ZONE="$(echo "${ZONE}" | cut -d '.' -f 2-)" |