summaryrefslogtreecommitdiffstats
path: root/bin/clean_challenge.nsupdate.sh
blob: 05ffb40b20588a07e74994e53abdf50f6d1d5927 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh

set -e

NAMESERVERS="$(kdig -4 +short @ns.bfh.science ns.bfh.science)"
ZONE="$(cat /etc/hostname | awk -F. '{ print $(NF-1) "." $NF}')"

for NAMESERVER in ${NAMESERVERS}
do
	echo -n " + Deleting TXT record (_acme-challenge.${DOMAIN})..."

	NSUPDATE="$(mktemp nsupdate.XXXX)"

cat > "${NSUPDATE}" << EOF
server ${NAMESERVER}
zone ${ZONE}
ttl 300
update delete _acme-challenge.${DOMAIN} 300 TXT ${TOKEN_VALUE}
send
EOF

	knsupdate "${NSUPDATE}"
	rm -f "${NSUPDATE}"

	echo " done."
done