update exit codes

This commit is contained in:
Matthew Saunders Brown 2023-08-08 13:22:11 -07:00
parent 8ba15ef4f0
commit d32c56685f

View File

@ -19,7 +19,7 @@ help()
echo " -h Print this help." echo " -h Print this help."
echo " -z <zone> Zone to get." echo " -z <zone> Zone to get."
echo echo
echo " Echoes 'true' if zone exists, 'false' if zone does not exist, 'error' with exit code 1 on error." echo " Echoes 'true' if zone exists with exit code 0, 'false' if zone does not exist with exit code 1, 'error' with exit code 2 on error."
} }
pdns:getoptions "$@" pdns:getoptions "$@"
@ -36,11 +36,13 @@ zone_status=$(/usr/bin/curl --silent --output /dev/null --write-out "%{http_code
if [[ $zone_status = 200 ]]; then if [[ $zone_status = 200 ]]; then
# zone exists # zone exists
echo true echo true
exit 0
elif [[ $zone_status = 404 ]]; then elif [[ $zone_status = 404 ]]; then
# zone does not exist # zone does not exist
echo false echo false
exit 1
else else
# error, unexpected response code # error, unexpected response code
echo error echo error
exit 1 exit 2
fi fi