From 49ea6a1bb9c2c3d24272b623ee407ff747be65df Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Tue, 27 Mar 2018 15:03:41 +0100 Subject: [PATCH] freedns: fix domain splitting for multi-part domains --- dnsapi/dns_freedns.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dnsapi/dns_freedns.sh b/dnsapi/dns_freedns.sh index 7262755e..61899e4a 100755 --- a/dnsapi/dns_freedns.sh +++ b/dnsapi/dns_freedns.sh @@ -47,11 +47,10 @@ dns_freedns_add() { _saveaccountconf FREEDNS_COOKIE "$FREEDNS_COOKIE" # split our full domain name into two parts... - i="$(echo "$fulldomain" | tr '.' ' ' | wc -w)" - i="$(_math "$i" - 1)" - top_domain="$(echo "$fulldomain" | cut -d. -f "$i"-100)" - i="$(_math "$i" - 1)" - sub_domain="$(echo "$fulldomain" | cut -d. -f -"$i")" + # top_domain is everything after the first dot + # sub_domain is the element before the first dot + top_domain="$(echo "$fulldomain" | cut -d. -f 2-)" + sub_domain="$(echo "$fulldomain" | cut -d. -f 1)" _debug "top_domain: $top_domain" _debug "sub_domain: $sub_domain"