Browse Source

Nameserver is automatically selected based on SOA

pull/1882/head
Marcel Schuhbauer 7 years ago
parent
commit
b3eaba8787
  1. 12
      dnsapi/dns_nsupdate.sh

12
dnsapi/dns_nsupdate.sh

@ -15,9 +15,15 @@ dns_nsupdate_add() {
_saveaccountconf NSUPDATE_SERVER_PORT "${NSUPDATE_SERVER_PORT}" _saveaccountconf NSUPDATE_SERVER_PORT "${NSUPDATE_SERVER_PORT}"
_saveaccountconf NSUPDATE_KEY "${NSUPDATE_KEY}" _saveaccountconf NSUPDATE_KEY "${NSUPDATE_KEY}"
_saveaccountconf NSUPDATE_KEYDIR "${NSUPDATE_KEYDIR}" _saveaccountconf NSUPDATE_KEYDIR "${NSUPDATE_KEYDIR}"
# try to find a matching key
if [ -r "${NSUPDATE_KEYDIR}/${basedomain}.key" ]; then if [ -r "${NSUPDATE_KEYDIR}/${basedomain}.key" ]; then
NSUPDATE_KEY="${NSUPDATE_KEYDIR}/${basedomain}.key" NSUPDATE_KEY="${NSUPDATE_KEYDIR}/${basedomain}.key"
_info "using non default key ${NSUPDATE_KEYDIR}/${basedomain}.key" _info "using non default key ${NSUPDATE_KEYDIR}/${basedomain}.key"
# try to use the current SOA of the domain as nameserver
if [ -n "$(command -v host)" ]; then
NSUPDATE_SERVER="$(host -t SOA "${basedomain}" | cut -d ' ' -f5 | sed 's/\.$//')"
_info "using non default server ${NSUPDATE_SERVER}"
fi
fi fi
_checkKeyFile || return 1 _checkKeyFile || return 1
_info "adding ${fulldomain}. 60 in txt \"${txtvalue}\"" _info "adding ${fulldomain}. 60 in txt \"${txtvalue}\""
@ -41,9 +47,15 @@ dns_nsupdate_rm() {
[ -n "${NSUPDATE_SERVER}" ] || NSUPDATE_SERVER="localhost" [ -n "${NSUPDATE_SERVER}" ] || NSUPDATE_SERVER="localhost"
[ -n "${NSUPDATE_SERVER_PORT}" ] || NSUPDATE_SERVER_PORT=53 [ -n "${NSUPDATE_SERVER_PORT}" ] || NSUPDATE_SERVER_PORT=53
[ -n "${NSUPDATE_KEYDIR}" ] || NSUPDATE_KEYDIR="${LE_WORKING_DIR}/keys" [ -n "${NSUPDATE_KEYDIR}" ] || NSUPDATE_KEYDIR="${LE_WORKING_DIR}/keys"
# try to find a matching key
if [ -r "${NSUPDATE_KEYDIR}/${basedomain}.key" ]; then if [ -r "${NSUPDATE_KEYDIR}/${basedomain}.key" ]; then
NSUPDATE_KEY="${NSUPDATE_KEYDIR}/${basedomain}.key" NSUPDATE_KEY="${NSUPDATE_KEYDIR}/${basedomain}.key"
_info "using non default key ${NSUPDATE_KEYDIR}/${basedomain}.key" _info "using non default key ${NSUPDATE_KEYDIR}/${basedomain}.key"
# try to use the current SOA of the domain as nameserver
if [ -n "$(command -v host)" ]; then
NSUPDATE_SERVER="$(host -t SOA "${basedomain}" | cut -d ' ' -f5 | sed 's/\.$//')"
_info "using non default server ${NSUPDATE_SERVER}"
fi
fi fi
_checkKeyFile || return 1 _checkKeyFile || return 1
_info "removing ${fulldomain}. txt" _info "removing ${fulldomain}. txt"

Loading…
Cancel
Save