add option for comment on zone creation

This commit is contained in:
Matthew Saunders Brown 2024-02-02 16:26:12 -08:00
parent 9f590234c9
commit 6d40482100

View File

@ -14,13 +14,14 @@ help()
echo "$thisfilename"
echo "Add new zone to DNS"
echo ""
echo "usage: $thisfilename -z <zone> [-m <master>] [-t <type>] [-a <account>] [-b] [-h]"
echo "usage: $thisfilename -z <zone> [-m <master>] [-t <type>] [-a <account>] [-w <comment>] [-b] [-h]"
echo ""
echo " -h Print this help."
echo " -z <zone> Zone (domain name) to add."
echo " -m <master> IP address of master, if this zone is of type SLAVE."
echo " -t <type> Defaults to NATIVE. Can also be MASTER or SLAVE. If type is SLAVE be sure to set master IP."
echo " -a <account> The account that controls this zones. For tying in to Control Panel or other custom admins."
echo " -a <account> Account that controls this zones. For tying in to Control Panel or other custom admins."
echo " -w <comment> 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