mirror of
https://github.com/acmesh-official/acme.sh.git
synced 2025-05-05 23:17:41 +00:00
Remove some bash specific string handling, replace with sed.
Plus some more code cleanup.
This commit is contained in:
parent
03ec57a054
commit
c1dece1cfb
@ -75,13 +75,13 @@ dns_freedns_add() {
|
|||||||
# interested in.
|
# interested in.
|
||||||
|
|
||||||
# Now we have to read through this table and extract the data we need
|
# Now we have to read through this table and extract the data we need
|
||||||
lines=$(echo "$subdomain_csv" | wc -l)
|
lines="$(echo "$subdomain_csv" | wc -l)"
|
||||||
nl='
|
nl='
|
||||||
'
|
'
|
||||||
i=0
|
i=0
|
||||||
found=0
|
found=0
|
||||||
while [ $i -lt $lines ]; do
|
while [ "$i" -lt "$lines" ]; do
|
||||||
i=$(_math $i + 1 )
|
i="$(_math "$i" + 1)"
|
||||||
line="$(echo "$subdomain_csv" | cut -d "$nl" -f $i)"
|
line="$(echo "$subdomain_csv" | cut -d "$nl" -f $i)"
|
||||||
tmp="$(echo "$line" | cut -d ',' -f 1)"
|
tmp="$(echo "$line" | cut -d ',' -f 1)"
|
||||||
if [ $found = 0 ] && _startswith "$tmp" "<td>$top_domain"; then
|
if [ $found = 0 ] && _startswith "$tmp" "<td>$top_domain"; then
|
||||||
@ -93,23 +93,16 @@ dns_freedns_add() {
|
|||||||
found=1
|
found=1
|
||||||
else
|
else
|
||||||
# lines contain DNS records for all subdomains
|
# lines contain DNS records for all subdomains
|
||||||
dns_href="$(echo "$line" | cut -d ',' -f 2)"
|
DNSname="$(echo "$line" | cut -d ',' -f 2 | sed 's/^[^>]*>//;s/<\/a>.*//')"
|
||||||
tmp=${dns_href#*>}
|
|
||||||
DNSname=${tmp%%<*}
|
|
||||||
DNStype="$(echo "$line" | cut -d ',' -f 3)"
|
DNStype="$(echo "$line" | cut -d ',' -f 3)"
|
||||||
if [ "$DNSname" = "$fulldomain" ] && [ "$DNStype" = "TXT" ]; then
|
if [ "$DNSname" = "$fulldomain" ] && [ "$DNStype" = "TXT" ]; then
|
||||||
tmp=${dns_href#*=}
|
DNSdataid="$(echo "$line" | cut -d ',' -f 2 | sed 's/^.*data_id=//;s/>.*//')"
|
||||||
url=${tmp%%>*}
|
|
||||||
DNSdataid=${url#*data_id=}
|
|
||||||
# Now get current value for the TXT record. This method may
|
# Now get current value for the TXT record. This method may
|
||||||
# produce inaccurate results as the value field is truncated
|
# not produce accurate results as the value field is truncated
|
||||||
# on this webpage. To get full value we would need to load
|
# on this webpage. To get full value we would need to load
|
||||||
# another page. However we don't really need this so long as
|
# another page. However we don't really need this so long as
|
||||||
# there is only one TXT record for the acme chalenge subdomain.
|
# there is only one TXT record for the acme chalenge subdomain.
|
||||||
tmp="$(echo "$line" | cut -d ',' -f 4)"
|
DNSvalue="$(echo "$line" | cut -d ',' -f 4 | sed 's/^[^"]*"//;s/".*//;s/<\/td>.*//')"
|
||||||
# strip the html double-quotes off the value
|
|
||||||
tmp=${tmp#"}
|
|
||||||
DNSvalue=${tmp%"}
|
|
||||||
if [ $found != 0 ]; then
|
if [ $found != 0 ]; then
|
||||||
break
|
break
|
||||||
# we are breaking out of the loop at the first match of DNS name
|
# we are breaking out of the loop at the first match of DNS name
|
||||||
@ -207,26 +200,19 @@ dns_freedns_rm() {
|
|||||||
# interested in.
|
# interested in.
|
||||||
|
|
||||||
# Now we have to read through this table and extract the data we need
|
# Now we have to read through this table and extract the data we need
|
||||||
lines=$(echo "$subdomain_csv" | wc -l)
|
lines="$(echo "$subdomain_csv" | wc -l)"
|
||||||
nl='
|
nl='
|
||||||
'
|
'
|
||||||
i=0
|
i=0
|
||||||
found=0
|
found=0
|
||||||
while [ $i -lt $lines ]; do
|
while [ "$i" -lt "$lines" ]; do
|
||||||
i=$(_math $i + 1 )
|
i="$(_math "$i" + 1)"
|
||||||
line="$(echo "$subdomain_csv" | cut -d "$nl" -f $i)"
|
line="$(echo "$subdomain_csv" | cut -d "$nl" -f $i)"
|
||||||
dns_href="$(echo "$line" | cut -d ',' -f 2)"
|
DNSname="$(echo "$line" | cut -d ',' -f 2 | sed 's/^[^>]*>//;s/<\/a>.*//')"
|
||||||
tmp=${dns_href#*>}
|
|
||||||
DNSname=${tmp%%<*}
|
|
||||||
DNStype="$(echo "$line" | cut -d ',' -f 3)"
|
DNStype="$(echo "$line" | cut -d ',' -f 3)"
|
||||||
if [ "$DNSname" = "$fulldomain" ] && [ "$DNStype" = "TXT" ]; then
|
if [ "$DNSname" = "$fulldomain" ] && [ "$DNStype" = "TXT" ]; then
|
||||||
tmp=${dns_href#*=}
|
DNSdataid="$(echo "$line" | cut -d ',' -f 2 | sed 's/^.*data_id=//;s/>.*//')"
|
||||||
url=${tmp%%>*}
|
DNSvalue="$(echo "$line" | cut -d ',' -f 4 | sed 's/^[^"]*"//;s/".*//;s/<\/td>.*//')"
|
||||||
DNSdataid=${url#*data_id=}
|
|
||||||
tmp="$(echo "$line" | cut -d ',' -f 4)"
|
|
||||||
# strip the html double-quotes off the value
|
|
||||||
tmp=${tmp#"}
|
|
||||||
DNSvalue=${tmp%"}
|
|
||||||
_debug "DNSvalue: $DNSvalue"
|
_debug "DNSvalue: $DNSvalue"
|
||||||
# if [ "$DNSvalue" = "$txtvalue" ]; then
|
# if [ "$DNSvalue" = "$txtvalue" ]; then
|
||||||
# Testing value match fails. Website is truncating the value
|
# Testing value match fails. Website is truncating the value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user