summaryrefslogtreecommitdiffstats
path: root/dehydrated/bin/dehydrated-nsupdate
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2021-09-04 16:24:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2021-09-04 16:26:00 +0000
commit0e89d5acfed08eacda5b620a29232a04ef388c47 (patch)
tree196be3b06fa94e2262f6371a104496ce98c9a626 /dehydrated/bin/dehydrated-nsupdate
parentReleasing debian version 20210828-2. (diff)
downloadopen-infrastructure-service-tools-0e89d5acfed08eacda5b620a29232a04ef388c47.tar.xz
open-infrastructure-service-tools-0e89d5acfed08eacda5b620a29232a04ef388c47.zip
Merging upstream version 20210904.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dehydrated/bin/dehydrated-nsupdate')
-rwxr-xr-xdehydrated/bin/dehydrated-nsupdate38
1 files changed, 33 insertions, 5 deletions
diff --git a/dehydrated/bin/dehydrated-nsupdate b/dehydrated/bin/dehydrated-nsupdate
index f901d2e..ec8cf7f 100755
--- a/dehydrated/bin/dehydrated-nsupdate
+++ b/dehydrated/bin/dehydrated-nsupdate
@@ -1,5 +1,24 @@
#!/bin/sh
+# Open Infrastructure: service-tools
+
+# Copyright (C) 2014-2021 Daniel Baumann <daniel.baumann@open-infrastructure.net>
+#
+# SPDX-License-Identifier: GPL-3.0+
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
set -e
HOOK="$(basename "${0}")"
@@ -50,18 +69,27 @@ else
exit 1
fi
+# config
+for FILE in /etc/default/dehydrated-nsupdate /etc/default/dehydrated-nsupdate.d/*
+do
+ if [ -e "${FILE}" ]
+ then
+ . "${FILE}"
+ fi
+done
+
# find txt record to update
CNAME="$(${DIG} "_acme-challenge.${DOMAIN}" 2>&1 | awk '/CNAME/ { print $5 }' | tail -n1)"
if [ -n "${CNAME}" ]
then
- UPDATE_DOMAIN="${CNAME}"
+ TXT_RECORD="${CNAME}"
else
- UPDATE_DOMAIN="_acme-challenge.${DOMAIN}"
+ TXT_RECORD="_acme-challenge.${DOMAIN}"
fi
# find nameservers to update
-ZONE="${UPDATE_DOMAIN}"
+ZONE="${TXT_RECORD}"
while true
do
@@ -80,12 +108,12 @@ NAMESERVERS="$(${DIG} +short NS "${ZONE}")"
# update nameservers
for NAMESERVER in ${NAMESERVERS}
do
- echo -n " + Adding TXT record (${UPDATE_DOMAIN})..."
+ echo -n " + sending '${HOOK_ACTION}' for ${TXT_RECORD} to ${NAMESERVER}..."
echo "server ${NAMESERVER}
zone ${ZONE}
ttl 0
-update ${HOOK_ACTION} ${UPDATE_DOMAIN} 0 TXT ${TOKEN_VALUE}
+update ${HOOK_ACTION} ${TXT_RECORD} 0 TXT ${TOKEN_VALUE}
send" | "${NSUPDATE}"
echo " done."