diff --git a/dnsapi/dns_geos.sh b/dnsapi/dns_geos.sh index 423ff883..3cd8997e 100644 --- a/dnsapi/dns_geos.sh +++ b/dnsapi/dns_geos.sh @@ -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 "(?<=