From ad097a5b29e068debc14f8439abe78441638e0b6 Mon Sep 17 00:00:00 2001 From: Tim Kimber Date: Tue, 15 Sep 2020 15:37:41 +0100 Subject: [PATCH] Add bad gateway retry logic to duckdns del command --- dns_scripts/dns_del_duckdns | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/dns_scripts/dns_del_duckdns b/dns_scripts/dns_del_duckdns index f20c664..bdb653c 100755 --- a/dns_scripts/dns_del_duckdns +++ b/dns_scripts/dns_del_duckdns @@ -3,8 +3,17 @@ # need to add your Token for duckdns below token=${DUCKDNS_TOKEN:-} domain="$1" +i=1 response=$(curl --retry 5 --silent "https://www.duckdns.org/update?domains=${domain}&token=${token}&txt=&clear=true") + +while [[ "${response}" == *"502 Bad Gateway"* ]] && [ $i -le 5 ]; do + echo "Retrying Bad Gateway response (attempt $i of 5)" + sleep 5 + i=$((i+1)) + response=$(curl --retry 5 --silent "https://www.duckdns.org/update?domains=${domain}&token=${token}&txt=&clear=true") +done + if [ "$response" != "OK" ]; then echo "Failed to update TXT record for ${domain} at duckdns.org (is the TOKEN valid?)" echo "$response"