remove rev command

This commit is contained in:
alviy 2024-04-27 09:55:38 +03:00 committed by GitHub
parent e814cccc44
commit dbe7cb8dbb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -102,7 +102,15 @@ dns_alviy_rm() {
# _domain=domain.com # _domain=domain.com
_get_root() { _get_root() {
domain=$1 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 if [ -z "$h" ]; then
#not valid #not valid
_alviy_rest GET "zone/$domain/" _alviy_rest GET "zone/$domain/"
@ -117,7 +125,8 @@ _get_root() {
if _contains "$response" '"code":"NOT_FOUND"'; then if _contains "$response" '"code":"NOT_FOUND"'; then
_debug "$h not found" _debug "$h not found"
else 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" _domain="$h"
return 0 return 0
fi fi