From bc7e02b47a7b04c367e08962a84a63170701f890 Mon Sep 17 00:00:00 2001
From: lufi42 <101186892+lufi42@users.noreply.github.com>
Date: Sun, 10 Jul 2022 17:11:27 +0200
Subject: [PATCH] Fixed removal of TXT record when subdomain is case-sensitive
and improved debug logging
Plesk SPI return domain names always lower-case. Therefore the search for domain names in the API response must be case-insensitve. Set debug logging to the values that are reallys used for the spi calls.
added comment
---
dnsapi/dns_pleskxml.sh | 23 ++++++++---------------
1 file changed, 8 insertions(+), 15 deletions(-)
diff --git a/dnsapi/dns_pleskxml.sh b/dnsapi/dns_pleskxml.sh
index 56902e20..a8f7f7be 100644
--- a/dnsapi/dns_pleskxml.sh
+++ b/dnsapi/dns_pleskxml.sh
@@ -145,32 +145,25 @@ dns_pleskxml_rm() {
)"
if [ -z "$reclist" ]; then
- _err "No TXT records found for root domain ${root_domain_name} (Plesk domain ID ${root_domain_id}). Exiting."
+ _err "No TXT records found for root domain $fulldomain (Plesk domain ID ${root_domain_id}). Exiting."
return 1
fi
- _debug "Got list of DNS TXT records for root domain '$root_domain_name':"
+ _debug "Got list of DNS TXT records for root Plesk domain ID ${root_domain_id} of root domain $fulldomain:"
_debug "$reclist"
- recline="$(
- _value "$reclist" |
- grep "${fulldomain}." |
- grep "${txtvalue}"
- )"
-
- _debug "Got line for ${fulldomain}. and ${txtvalue}:"
- _debug "$recline"
-
+ # Extracting the id of the TXT record for the full domain (NOT case-sensitive) and corresponding value
recid="$(
- _value "$recline" |
+ _value "$reclist" |
+ grep -i "${fulldomain}." |
+ grep "${txtvalue}" |
sed 's/^.*\([0-9]\{1,\}\)<\/id>.*$/\1/'
)"
- _debug "Got id from line:"
- _debug "$recid"
+ _debug "Got id from line: $recid"
if ! _value "$recid" | grep '^[0-9]\{1,\}$' >/dev/null; then
- _err "DNS records for root domain '${root_domain_name}' (Plesk ID ${root_domain_id}) + host '${sub_domain_name}' do not contain the TXT record '${txtvalue}'"
+ _err "DNS records for root domain '${fulldomain}.' (Plesk ID ${root_domain_id}) + host '${sub_domain_name}' do not contain the TXT record '${txtvalue}'"
_err "Cannot delete TXT record. Exiting."
return 1
fi