From b7cd35384c00475963828dbf6863b38d24c0decb Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Tue, 6 Feb 2024 10:34:24 -0800 Subject: [PATCH] add exit codes --- bin/pdns-zone-add.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/pdns-zone-add.sh b/bin/pdns-zone-add.sh index 86380ed..1bf58dd 100755 --- a/bin/pdns-zone-add.sh +++ b/bin/pdns-zone-add.sh @@ -30,7 +30,7 @@ pdns:getoptions "$@" # check for zone if [[ -z $zone ]]; then echo "zone is required" - exit + exit 1 fi # 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 echo Zone $zone already exists. + exit 1 elif [[ $zone_status = 404 ]]; then # zone does not exist, create new zone now @@ -159,10 +160,13 @@ elif [[ $zone_status = 404 ]]; then if [[ $zone_status = 201 ]]; then echo Success. Zone $zone created. + exit 0 else echo Error. http response adding zone $zone was: $zone_status + exit 1 fi else echo Unexpected http response checking for Zone $zone: $zone_status + exit 1 fi