-
Notifications
You must be signed in to change notification settings - Fork 6
/
cleanup.sh
executable file
·40 lines (32 loc) · 919 Bytes
/
cleanup.sh
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash -ex
# load config
. "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/config.sh"
# load base
. "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/base.sh"
# certbot environment variables
dnsExitToken="${DNSEXIT_TOKEN}"
dnsExitBaseDomains="${DNSEXIT_BASE_DOMAINS}"
certbotDomain="${CERTBOT_DOMAIN}"
validation="${CERTBOT_VALIDATION}"
filename="update.json"
# get matching dnsExit base domain from certbot provided domain
getDnsExitDomain dnsExitBaseDomain "${certbotDomain}" "${dnsExitBaseDomains}"
json=$(cat <<-END
{
"apikey": "${dnsExitToken}",
"domain": "${dnsExitBaseDomain}",
"delete": {
"type": "TXT",
"name": "_acme-challenge.${certbotDomain}"
}
}
END
)
# write json file
echo "${json}" > ${filename}
# delete txt record
curl -H "Content-Type: application/json" --data @${filename} https://api.dnsexit.com/dns/
# cleanup
rm -f /tmp/dnsExit*.*
exit 0
exit 0