summaryrefslogtreecommitdiff
path: root/scripts/acme/dns-clean.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/acme/dns-clean.sh')
-rwxr-xr-xscripts/acme/dns-clean.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/scripts/acme/dns-clean.sh b/scripts/acme/dns-clean.sh
new file mode 100755
index 0000000..0eeab27
--- /dev/null
+++ b/scripts/acme/dns-clean.sh
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+if [[ -z "${CERTBOT_DOMAIN}" || -z "${CERTBOT_VALIDATION}" ]]; then
+ echo "Environment not set"
+ exit 1
+fi
+
+ZONE=$(expr match "$CERTBOT_DOMAIN" '.*\.\(.*\..*\)')
+NAMEONLY=$(expr match "$CERTBOT_DOMAIN" '\(.*\.\).*\..*')
+CREATE_DOMAIN="_acme-challenge.${NAMEONLY}"
+
+pdnsutil delete-rrset ${ZONE} ${CREATE_DOMAIN} TXT
+pdnsutil increase-serial "${ZONE}"
+pdns_control notify "${ZONE}"