From 2ac17121d286831ceecd682804443261cfe60406 Mon Sep 17 00:00:00 2001 From: sjau Date: Tue, 22 Nov 2016 14:29:08 +0100 Subject: [PATCH] Refactored the _ISPC_rmTxt() function --- dnsapi/dns_ispconfig.sh | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/dnsapi/dns_ispconfig.sh b/dnsapi/dns_ispconfig.sh index 95c39643..768d9fe3 100755 --- a/dnsapi/dns_ispconfig.sh +++ b/dnsapi/dns_ispconfig.sh @@ -150,23 +150,19 @@ _ISPC_rmTxt() { _debug "Record ID is not numeric." return 1 ;; - *) _info "Successfully retrieved Record ID" ;; + *) + _info "Successfully retrieved Record ID" + curData="{\"session_id\":\"${sessionID}\",\"primary_id\":\"${record_id}\"}" + curResult="$(_post "${curData}" "${ISPC_Api}?dns_txt_delete")" + if _contains "${curResult}" '"code":"ok"'; then + _info "Successfully removed ACME challenge txt record." + else + # Setting it to debug only because there's no harm if the txt record remains + _debug "Couldn't remove ACME challenge txt record." + return 1 + fi + ;; esac fi done - # Check if a record id was found - if [ -z "${record_id}" ]; then - _debug "No Record ID found for '${fulldomain}'" - return 1 - fi - # Delete the record - curData="{\"session_id\":\"${sessionID}\",\"primary_id\":\"${record_id}\"}" - curResult="$(_post "${curData}" "${ISPC_Api}?dns_txt_delete")" - if _contains "${curResult}" '"code":"ok"'; then - _info "Successfully removed ACME challenge txt record." - else - # Setting it to debug only because there's no harm if the txt record remains - _debug "Couldn't remove ACME challenge txt record." - return 1 - fi }