From 8ba15ef4f066741f0ae1741919757e4cd18f78fd Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Tue, 8 Aug 2023 13:21:39 -0700 Subject: [PATCH] add -d (domain) option as alias to -z (zone) --- bin/pdns.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/pdns.sh b/bin/pdns.sh index 37e876c..765cb27 100755 --- a/bin/pdns.sh +++ b/bin/pdns.sh @@ -122,7 +122,7 @@ function pdns::yesno() { function pdns:getoptions () { local OPTIND - while getopts "hbz:m:t:a:n:r:c:l:s:x" opt ; do + while getopts "hbz:d:m:t:a:n:r:c:l:s:x" opt ; do case "${opt}" in h ) # display help and exit help @@ -142,6 +142,17 @@ function pdns:getoptions () { exit fi ;; + d ) # domain (alias of zone) + zone=${OPTARG,,} + # pdns stores zone name without trailing dot, remove if found + if [[ ${zone: -1} = '.' ]]; then + zone=${zone::-1} + fi + if ! vmail::validate_domain $zone; then + echo "ERROR: $zone is not a valid domain name." + exit + fi + ;; m ) # master - IP of master if this is a slave zone master=${OPTARG} ;;