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} ;;