Record ID for removal can be accessed directly now

This commit is contained in:
hyper 2016-11-23 17:06:24 +01:00
parent c32a62a4c4
commit d072b2c9f8

View File

@ -132,32 +132,28 @@ _ISPC_addTxt() {
_ISPC_rmTxt() { _ISPC_rmTxt() {
# Need to get the record ID. # Need to get the record ID.
curData="{\"session_id\":\"${sessionID}\",\"primary_id\":[{\"name\":\"${fulldomain}.\"}]}" primary="\"primary_id\":{\"name\":\"${fulldomain}.\",\"type\":\"TXT\"}"
curData="{\"session_id\":\"${sessionID}\",\"primary_id\":{\"name\":\"${fulldomain}.\",\"type\":\"TXT\"}}"
curResult="$(_post "${curData}" "${ISPC_Api}?dns_txt_get")" curResult="$(_post "${curData}" "${ISPC_Api}?dns_txt_get")"
# The array search doesn't work properly... so we loop through all retrieved records and check if it contains $fulldomain if _contains "${curResult}" '"code":"ok"'; then
IFS='{' record_id=$(echo "${curResult}" | _egrep_o "\"id.*" | cut -d ':' -f 2 | cut -d '"' -f 2)
for i in ${curResult}; do case "${record_id}" in
if _contains "${i}" "${fulldomain}"; then '' | *[!0-9]*)
_info "Retrieved ACME Challenge TXT record." _err "Record ID is not numeric."
record_id=$(echo "${i}" | _egrep_o "\"id.*" | cut -d ':' -f 2 | cut -d '"' -f 2) return 1
case "${record_id}" in ;;
'' | *[!0-9]*) *)
_err "Record ID is not numeric." unset IFS
_info "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 "Removed ACME Challenge TXT record from zone."
else
_err "Couldn't remove ACME Challenge TXT record from zone."
return 1 return 1
;; fi
*) ;;
unset IFS esac
_info "Retrieved Record ID" fi
curData="{\"session_id\":\"${sessionID}\",\"primary_id\":\"${record_id}\"}"
curResult="$(_post "${curData}" "${ISPC_Api}?dns_txt_delete")"
if _contains "${curResult}" '"code":"ok"'; then
_info "Removed ACME Challenge TXT record from zone."
else
_err "Couldn't remove ACME Challenge TXT record from zone."
return 1
fi
;;
esac
fi
done
} }