Fixed regex in string array
Fixed grep regex in string array.
This commit is contained in:
parent
f93136c2f9
commit
af5a652e88
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/bash
|
||||
#!/usr/bin/env sh
|
||||
########################################################################
|
||||
# GeoScaling hook script for acme.sh
|
||||
#
|
||||
@ -70,10 +70,11 @@ dns_geos_rm() {
|
||||
_count() {
|
||||
echo "$1" | awk -F"$2" '{print NF-1}'
|
||||
}
|
||||
|
||||
#$1:fullname,eg:_acme-challenge.us.domain.com
|
||||
#ret:return root domain,us.domain.com domain.com
|
||||
#Usage: local -a domains=(); _get_domain "_acme-challenge.us.domain.com" domains
|
||||
#$1:fullname
|
||||
#$2:return root domain array,us.domain.com domain.com
|
||||
_get_domain() {
|
||||
local -n arr=$2 #use nameref for indirection
|
||||
i=2
|
||||
c=$(_count "$1" ".")
|
||||
while [ $i -le "$c" ]; do
|
||||
@ -81,7 +82,7 @@ _get_domain() {
|
||||
if [ -z "$h" ]; then
|
||||
return 1
|
||||
fi
|
||||
echo "$h"
|
||||
arr+=("$h")
|
||||
i=$(_math "$i" + 1)
|
||||
done
|
||||
return 0
|
||||
@ -121,13 +122,15 @@ _get_zone() {
|
||||
response=$(_get "https://www.geoscaling.com/dns2/index.php?module=domains")
|
||||
table=$(echo "$response" | tr -d "\n" | grep -oP "(?<=<table border='0' align='center' cellpadding='10' cellspacing='10' class=\"threecolumns\">).*?(?=</table>)")
|
||||
items=$(echo "$table" | grep -oP "(?<=<a).*?(?=</a>)")
|
||||
domains=$(_get_domain "$1")
|
||||
#_debug "items=$items"
|
||||
domains=()
|
||||
_get_domain "$1" domains || return 1
|
||||
for d in "${domains[@]}"; do
|
||||
id=$(echo "$items" | grep -oP "id=[0-9]*.*$d" | cut -d "'" -f 1)
|
||||
if [ -n "$id" ]; then
|
||||
_sub_domain=${1//.$d/}
|
||||
_zone_id=${id##*=}
|
||||
#echo "$_zone_id"
|
||||
_debug "zone_id=$_zone_id"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
Loading…
Reference in New Issue
Block a user