From 233d82147153b1a49b55a9742560293e3a028d33 Mon Sep 17 00:00:00 2001 From: Hobby-Student <6012744+Hobby-Student@users.noreply.github.com> Date: Thu, 4 Aug 2022 16:51:42 +0200 Subject: [PATCH] catching curl error with 2nd attempt --- dnsapi/dns_kas.sh | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/dnsapi/dns_kas.sh b/dnsapi/dns_kas.sh index e13d42b5..696f2725 100755 --- a/dnsapi/dns_kas.sh +++ b/dnsapi/dns_kas.sh @@ -19,7 +19,7 @@ # KAS_Api="$(echo "$KAS_Api_GET" | tr -d ' ' | grep -i "//g")" KAS_Api='https://kasapi.kasserver.com/soap/KasApi.php' _info "##KAS## Using $KAS_Api" -KAS_default_ratelimit=4 +KAS_default_ratelimit=5 ######## Public functions ##################### dns_kas_add() { _fulldomain=$1 @@ -56,6 +56,12 @@ dns_kas_add() { _sleep $KAS_default_ratelimit response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")" _debug2 "##KAS## response" "$response" + if [ -z "$response" ]; then + _info "##KAS## Response was empty, 2nd attempt" + _sleep $KAS_default_ratelimit + response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")" + _debug2 "##KAS## retry response" "$response" + fi if _contains "$response" ""; then if _contains "$response" "record_already_exists"; then @@ -106,6 +112,12 @@ dns_kas_rm() { _sleep $KAS_default_ratelimit response="$(_post "$params2" "$KAS_Api" "" "POST" "text/xml")" _debug2 "##KAS## response" "$response" + if [ -z "$response" ]; then + _info "##KAS## Response was empty, 2nd attempt" + _sleep $KAS_default_ratelimit + response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")" + _debug2 "##KAS## retry response" "$response" + fi if _contains "$response" ""; then _err "##KAS## Either the txt record was not found or another error occurred, please check manually." return 1 @@ -159,6 +171,12 @@ _get_zone_and_record_name() { _sleep $KAS_default_ratelimit response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")" _debug2 "##KAS## response" "$response" + if [ -z "$response" ]; then + _info "##KAS## Response was empty, 2nd attempt" + _sleep $KAS_default_ratelimit + response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")" + _debug2 "##KAS## retry response" "$response" + fi if _contains "$response" ""; then _err "##KAS## Either no domains were found or another error occurred, please check manually." return 1 @@ -202,6 +220,12 @@ _get_record_id() { _sleep $KAS_default_ratelimit response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")" _debug2 "##KAS## response" "$response" + if [ -z "$response" ]; then + _info "##KAS## Response was empty, 2nd attempt" + _sleep $KAS_default_ratelimit + response="$(_post "$params" "$KAS_Api" "" "POST" "text/xml")" + _debug2 "##KAS## retry response" "$response" + fi if _contains "$response" ""; then _err "##KAS## Either no zones were found or another error occurred, please check manually." return 1