From 6d40482100b5e77f02e724f746a619f47573b656 Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Fri, 2 Feb 2024 16:26:12 -0800 Subject: [PATCH] add option for comment on zone creation --- bin/pdns-zone-add.sh | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/bin/pdns-zone-add.sh b/bin/pdns-zone-add.sh index d97f2cd..86380ed 100755 --- a/bin/pdns-zone-add.sh +++ b/bin/pdns-zone-add.sh @@ -14,13 +14,14 @@ help() echo "$thisfilename" echo "Add new zone to DNS" echo "" - echo "usage: $thisfilename -z [-m ] [-t ] [-a ] [-b] [-h]" + echo "usage: $thisfilename -z [-m ] [-t ] [-a ] [-w ] [-b] [-h]" echo "" echo " -h Print this help." echo " -z Zone (domain name) to add." echo " -m IP address of master, if this zone is of type SLAVE." echo " -t Defaults to NATIVE. Can also be MASTER or SLAVE. If type is SLAVE be sure to set master IP." - echo " -a The account that controls this zones. For tying in to Control Panel or other custom admins." + echo " -a Account that controls this zones. For tying in to Control Panel or other custom admins." + echo " -w Write an optional comment/note. Will be associated with the SOA Resource Record." echo " -b Bare - create zone without any Resource Records. Normally a default set of RR are created." } @@ -78,6 +79,14 @@ elif [[ $zone_status = 404 ]]; then data="$data}" data="$data]" + # if set add comment, gets associated with SOA + if [[ -n $comment ]]; then + # set account to hostname if not specified with -a option + if [[ -z $account ]]; then + account=$(/usr/bin/hostname -f) + fi + data="$data,\"comments\":[{\"content\":\"$comment\",\"account\":\"$account\"}]" + fi if [[ -n $bare ]]; then # do not add default records @@ -154,8 +163,6 @@ elif [[ $zone_status = 404 ]]; then echo Error. http response adding zone $zone was: $zone_status fi - echo "data = $data" - else echo Unexpected http response checking for Zone $zone: $zone_status fi