add exit codes

This commit is contained in:
Matthew Saunders Brown 2024-02-06 10:34:24 -08:00
parent 6358759970
commit b7cd35384c

View File

@ -30,7 +30,7 @@ pdns:getoptions "$@"
# check for zone # check for zone
if [[ -z $zone ]]; then if [[ -z $zone ]]; then
echo "zone is required" echo "zone is required"
exit exit 1
fi fi
# first query to see if zone already exists # first query to see if zone already exists
@ -38,6 +38,7 @@ zone_status=$(/usr/bin/curl --silent --output /dev/null --write-out "%{http_code
if [[ $zone_status = 200 ]]; then if [[ $zone_status = 200 ]]; then
echo Zone $zone already exists. echo Zone $zone already exists.
exit 1
elif [[ $zone_status = 404 ]]; then elif [[ $zone_status = 404 ]]; then
# zone does not exist, create new zone now # zone does not exist, create new zone now
@ -159,10 +160,13 @@ elif [[ $zone_status = 404 ]]; then
if [[ $zone_status = 201 ]]; then if [[ $zone_status = 201 ]]; then
echo Success. Zone $zone created. echo Success. Zone $zone created.
exit 0
else else
echo Error. http response adding zone $zone was: $zone_status echo Error. http response adding zone $zone was: $zone_status
exit 1
fi fi
else else
echo Unexpected http response checking for Zone $zone: $zone_status echo Unexpected http response checking for Zone $zone: $zone_status
exit 1
fi fi