add error check for false or missing DNS Zone

This commit is contained in:
Aaron Riedel 2022-04-21 18:43:58 +02:00
parent 1f609cb222
commit 9f088db3a6
Signed by: aaron
GPG key ID: 643004654D40D577
2 changed files with 12 additions and 2 deletions

View file

@ -68,7 +68,12 @@ fi
############################################# #############################################
echo -e "${PENDING} get Zones" echo -e "${PENDING} get Zones"
HETZNER_API_ZONE=$(curl -s "https://dns.hetzner.com/api/v1/zones" -H "Auth-API-Token: ${HETZNER_API_TOKEN}" | jq -r ".zones[] | select(.name==\"$DNSZONE\") | .id") HETZNER_API_ZONE=$(curl -s "https://dns.hetzner.com/api/v1/zones" -H "Auth-API-Token: ${HETZNER_API_TOKEN}" | jq -r ".zones[] | select(.name==\"$DNSZONE\") | .id")
if [ -z $HETZNER_API_ZONE ]; then
echo -e "${REPLACE}${ERROR} get DNS Zone"
exit 1
else
echo -e "${REPLACE}${SUCCESS} get DNS Zone" echo -e "${REPLACE}${SUCCESS} get DNS Zone"
fi
############################################# #############################################
echo -e "${PENDING} Check DNS Console for existing records" echo -e "${PENDING} Check DNS Console for existing records"
RECORDS=$(curl -s "https://dns.hetzner.com/api/v1/records?zone_id=${HETZNER_API_ZONE}" \ RECORDS=$(curl -s "https://dns.hetzner.com/api/v1/records?zone_id=${HETZNER_API_ZONE}" \

View file

@ -68,7 +68,12 @@ fi
############################################# #############################################
echo -e "${PENDING} get Zones" echo -e "${PENDING} get Zones"
HETZNER_API_ZONE=$(curl -s "https://dns.hetzner.com/api/v1/zones" -H "Auth-API-Token: ${HETZNER_API_TOKEN}" | jq -r ".zones[] | select(.name==\"$DNSZONE\") | .id") HETZNER_API_ZONE=$(curl -s "https://dns.hetzner.com/api/v1/zones" -H "Auth-API-Token: ${HETZNER_API_TOKEN}" | jq -r ".zones[] | select(.name==\"$DNSZONE\") | .id")
if [ -z $HETZNER_API_ZONE ]; then
echo -e "${REPLACE}${ERROR} get DNS Zone"
exit 1
else
echo -e "${REPLACE}${SUCCESS} get DNS Zone" echo -e "${REPLACE}${SUCCESS} get DNS Zone"
fi
############################################# #############################################
echo -e "${PENDING} Check DNS Console for existing records" echo -e "${PENDING} Check DNS Console for existing records"
RECORDS=$(curl -s "https://dns.hetzner.com/api/v1/records?zone_id=${HETZNER_API_ZONE}" \ RECORDS=$(curl -s "https://dns.hetzner.com/api/v1/records?zone_id=${HETZNER_API_ZONE}" \