Skip to content

Commit

Permalink
remove rev command
Browse files Browse the repository at this point in the history
  • Loading branch information
alviy authored Apr 27, 2024
1 parent e814ccc commit dbe7cb8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions dnsapi/dns_alviy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ dns_alviy_rm() {
# _domain=domain.com
_get_root() {
domain=$1
h=$(printf "%s" "$domain" | rev | cut -d . -f 1-2 | rev)
i=3
a="init"
while [ ! -z $a ]
do
a=$(printf "%s" "$domain" | cut -d . -f $i-)
i=`expr $i + 1`
done
num=`expr $i - 3`
h=$(printf "%s" "$domain" | cut -d . -f $num-)
if [ -z "$h" ]; then
#not valid
_alviy_rest GET "zone/$domain/"
Expand All @@ -117,7 +125,8 @@ _get_root() {
if _contains "$response" '"code":"NOT_FOUND"'; then
_debug "$h not found"
else
_sub_domain=$(printf "%s" "$domain" | rev | cut -d . -f 3- | rev)
s_n=`expr $num - 1`
_sub_domain=$(printf "%s" "$domain" | cut -d . -f -$s_n)
_domain="$h"
return 0
fi
Expand Down

0 comments on commit dbe7cb8

Please sign in to comment.