From 5f8c86329935bef55736727ca00a3d459059ed59 Mon Sep 17 00:00:00 2001 From: Olle Gustafsson Date: Tue, 26 Nov 2019 17:20:53 +0100 Subject: [PATCH] Add PDNS Manager support --- dnsapi/dns_pdnsmanager.sh | 66 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 dnsapi/dns_pdnsmanager.sh diff --git a/dnsapi/dns_pdnsmanager.sh b/dnsapi/dns_pdnsmanager.sh new file mode 100644 index 00000000..23fd4895 --- /dev/null +++ b/dnsapi/dns_pdnsmanager.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env sh +# +# PDNS Manager wrapper script for acme.sh +# +# Author: Olle Gustafsson +# Report Bugs here: Just send an email, there are no bugs ;) +# +# https://pdnsmanager.org/ +# https://www.powerdns.com/ +# +# This script is using PDNS Manager's API to update TXT record since giving API +# access to PowerDNS API itself is not possible for a single domain (or record). +# +# Before first run; export these variables or failure is imminent. +# +# export PDNS_MANAGER_URL=https://pdnsmanager.domain.nx +# export PDNS_MANAGER_RECORDID= +# export PDNS_MANAGER_PASSWORD= +# +# Then run: +# +# acme.sh --issue --staging --dns dns_pdnsmanager -d domaintovalidate.nx +# +# Remember to remove --staging in production +# + +# Usage: dns_pdnsmanager_add _acme-challenge.www.domain.com "XKrxpRBosdIKFzxW_CT3KLZNf6q0HG9i01zxXp5CPBs" + +dns_pdnsmanager_add() { + fulldomain=$1 + txtvalue=$2 + _info "Using PDNS Manager" + _debug fulldomain "$fulldomain" + _debug txtvalue "$txtvalue" + + PDNS_MANAGER_URL="${PDNS_MANAGER_URL:-$(_readaccountconf_mutable PDNS_MANAGER_URL)}" + PDNS_MANAGER_RECORDID="${PDNS_MANAGER_RECORDID:-$(_readaccountconf_mutable PDNS_MANAGER_RECORDID)}" + PDNS_MANAGER_PASSWORD="${PDNS_MANAGER_PASSWORD:-$(_readaccountconf_mutable PDNS_MANAGER_PASSWORD)}" + if [ -z "$PDNS_MANAGER_URL" ] || [ -z "$PDNS_MANAGER_RECORDID" ] || [ -z "$PDNS_MANAGER_PASSWORD" ]; then + PDNS_MANAGER_URL="" + PDNS_MANAGER_RECORDID="" + PDNS_MANAGER_PASSWORD="" + _err "PDNS_MANAGER_URL, PDNS_MANAGER_RECORDID and/or PDNS_MANAGER_PASSWORD is missing!" + _err "Please export these variables and try again." + return 1 + fi + + _saveaccountconf_mutable PDNS_MANAGER_RECORDID "$PDNS_MANAGER_RECORDID" + _saveaccountconf_mutable PDNS_MANAGER_PASSWORD "$PDNS_MANAGER_PASSWORD" + + _get "${PDNS_MANAGER_URL}/api/v1/remote/updatepw?record=${PDNS_MANAGER_RECORDID}&password=${PDNS_MANAGER_PASSWORD}&content=${txtvalue}" + + return 0 +} + +# Usage: fulldomain txtvalue +# Remove the txt record after validation. +# +# Not implemented since no new records will be created. +dns_pdnsmanager_rm() { + fulldomain=$1 + txtvalue=$2 + # _info "Using PDNS Manager" + # _debug fulldomain "$fulldomain" + # _debug txtvalue "$txtvalue" +}