From bc14e2ba4ae547fd9e449a4336f67b669e7a970e Mon Sep 17 00:00:00 2001 From: gaby64 Date: Thu, 31 Mar 2022 11:19:45 -0400 Subject: [PATCH] correctly handle any fulldomain how is this algorithm for finding the root domain, it can handle "example.com.br" --- dnsapi/dns_acmedns.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dnsapi/dns_acmedns.sh b/dnsapi/dns_acmedns.sh index 1fcd4c77..ee42d5d7 100755 --- a/dnsapi/dns_acmedns.sh +++ b/dnsapi/dns_acmedns.sh @@ -20,8 +20,15 @@ # Used to add txt record dns_acmedns_add() { fulldomain=$1 - i=2 - d=$(printf "%s" "$fulldomain" | cut -d . -f $i-100) + i=1 + while [ -z "$d" ]; do + _d=$(printf "%s" "$fulldomain" | cut -d . -f $i-100) + c=$(echo $_d | awk -F'.' '{ print NF }') + if [[ $c < 4 && ( $(echo $_d | cut -d . -f 2) = "com" || $(echo $_d | cut -d . -f 3) = "" ) ]]; then + d=$_d + fi + i=$(_math "$i" + 1) + done h="${d/./_}" txtvalue=$2 _info "Using acme-dns"