Browse Source

Correctly handle .co.uk type domains

pull/2700/head
Radek SPRTA 5 years ago
parent
commit
69392f67e8
No known key found for this signature in database GPG Key ID: 3C36A3AA4A06D51
  1. 15
      dnsapi/dns_clouddns.sh

15
dnsapi/dns_clouddns.sh

@ -118,15 +118,24 @@ dns_clouddns_rm() {
# _domain_id=sdjkglgdfewsdfg # _domain_id=sdjkglgdfewsdfg
_get_root() { _get_root() {
domain=$1 domain=$1
domain_root=$(echo "$fulldomain" | _egrep_o '\.([^\.]*\.[^\.]*)$' | cut -c 2-)
# Get domain root
data="{\"search\": [{\"name\": \"clientId\", \"operator\": \"eq\", \"value\": \"$CLOUDDNS_CLIENT_ID\"}]}"
response="$(_clouddns_api "POST" "domain/search" "$data" | tr -d '\t\r\n ')"
_debug2 "response" "$response"
domain_slice="$domain"
while [ -z "$domain_root" ]; do
if _contains "$response" "\"domainName\":\"$domain_slice\.\""; then
domain_root="$domain_slice"
_debug domain_root "$domain_root" _debug domain_root "$domain_root"
fi
domain_slice="$(echo "$domain_slice" | cut -d . -f 2-)"
done
# Get domain id # Get domain id
data="{\"search\": [{\"name\": \"clientId\", \"operator\": \"eq\", \"value\": \"$CLOUDDNS_CLIENT_ID\"}, \ data="{\"search\": [{\"name\": \"clientId\", \"operator\": \"eq\", \"value\": \"$CLOUDDNS_CLIENT_ID\"}, \
{\"name\": \"domainName\", \"operator\": \"eq\", \"value\": \"$domain_root.\"}]}" {\"name\": \"domainName\", \"operator\": \"eq\", \"value\": \"$domain_root.\"}]}"
response="$(_clouddns_api "POST" "domain/search" "$data" | tr -d '\t\r\n ')" response="$(_clouddns_api "POST" "domain/search" "$data" | tr -d '\t\r\n ')"
_debug "Domain id $response"
if _contains "$response" "\"id\":\""; then if _contains "$response" "\"id\":\""; then
re='domainType\":\"[^\"]*\",\"id\":\"([^\"]*)\",' # Match domain id re='domainType\":\"[^\"]*\",\"id\":\"([^\"]*)\",' # Match domain id
_domain_id=$(echo "$response" | _egrep_o "$re" | _head_n 1 | cut -d : -f 3 | tr -d "\",") _domain_id=$(echo "$response" | _egrep_o "$re" | _head_n 1 | cut -d : -f 3 | tr -d "\",")

Loading…
Cancel
Save