bind_add_dkim_zone_master.sh: Support adding DKIM zone even if zone is not yet official responsible.

This commit is contained in:
2025-11-05 22:10:19 +01:00
parent 27edc58ca6
commit fc1de89b2b

View File

@@ -96,6 +96,12 @@ usage() {
-k <tsig key name> -k <tsig key name>
Name of the TSIG key used for dynamical updates. Name of the TSIG key used for dynamical updates.
-m <dns_master>
Main Domains Master DNS Server
-s <dns_slave>
Main Domains Slave DNS Server
-t <allow-transfer options> -t <allow-transfer options>
allow-transfer for zone declaration. Possible values are ip-address(es) allow-transfer for zone declaration. Possible values are ip-address(es)
or existing 'acl' defininition(s). or existing 'acl' defininition(s).
@@ -290,6 +296,10 @@ while getopts hk:qt: opt ; do
;; ;;
k) TSIG_KEY_NAME="$OPTARG" k) TSIG_KEY_NAME="$OPTARG"
;; ;;
m) DNS_MASTER="$OPTARG"
;;
s) DNS_SLAVE="$OPTARG"
;;
q) verbose=true q) verbose=true
;; ;;
t) ALLOW_TRANSFER_OPTION="$OPTARG" t) ALLOW_TRANSFER_OPTION="$OPTARG"
@@ -430,18 +440,22 @@ fi
# - Get DNS server # - Get DNS server
# - # -
echononl "Get responsible zone for domain '$dkim_domain'.." echononl "Get responsible zone for domain '$dkim_domain'.."
found=true if [[ -n "${DNS_MASTER}" ]] && [[ -n "${DNS_SLAVE}" ]] ; then
zone="${dkim_domain}" echo_skipped
dns_servers="$(dig +short $zone NS 2>/dev/null)" dns_server_arr=("${DNS_MASTER}" "${DNS_SLAVE}")
while [[ -z "$dns_servers" ]] ; do else
found=true
zone="${dkim_domain}"
dns_servers="$(dig +short $zone NS 2>/dev/null)"
while [[ -z "$dns_servers" ]] ; do
zone=${zone#*.} zone=${zone#*.}
if [[ ! $zone =~ \. ]]; then if [[ ! $zone =~ \. ]]; then
found=false found=false
break break
fi fi
dns_servers="$(dig +short $zone NS 2>/dev/null)" dns_servers="$(dig +short $zone NS 2>/dev/null)"
done done
if $found ; then if $found ; then
echo_ok echo_ok
info "Found responsible zone for '${dkim_domain}': \033[37m\033[1m${zone}\033[m" info "Found responsible zone for '${dkim_domain}': \033[37m\033[1m${zone}\033[m"
echononl "Get nameservers for domain '${zone}'.." echononl "Get nameservers for domain '${zone}'.."
@@ -462,10 +476,11 @@ if $found ; then
info "Found nameservers \033[37m\033[1m${_tmp_dns_server}\033[m" info "Found nameservers \033[37m\033[1m${_tmp_dns_server}\033[m"
fi fi
done done
else else
echo_failed echo_failed
error "No responsible zone for '$dkim_domain' found!" error "No responsible zone for '$dkim_domain' found!"
clean_up 16 clean_up 16
fi
fi fi