|
@ -1,4 +1,3 @@ |
|
|
|
|
|
|
|
|
#!/usr/bin/env sh |
|
|
#!/usr/bin/env sh |
|
|
|
|
|
|
|
|
#This file name is "dns_freedns.sh" |
|
|
#This file name is "dns_freedns.sh" |
|
@ -60,16 +59,16 @@ dns_freedns_add() { |
|
|
|
|
|
|
|
|
# Now convert the tables in the HTML to CSV. This litte gem from |
|
|
# Now convert the tables in the HTML to CSV. This litte gem from |
|
|
# http://stackoverflow.com/questions/1403087/how-can-i-convert-an-html-table-to-csv |
|
|
# http://stackoverflow.com/questions/1403087/how-can-i-convert-an-html-table-to-csv |
|
|
subdomain_csv="$(echo $htmlpage | |
|
|
|
|
|
grep -i -e '</\?TABLE\|</\?TD\|</\?TR\|</\?TH' | |
|
|
|
|
|
sed 's/^[\ \t]*//g' | |
|
|
|
|
|
tr -d '\n' | |
|
|
|
|
|
sed 's/<\/TR[^>]*>/\n/Ig' | |
|
|
|
|
|
sed 's/<\/\?\(TABLE\|TR\)[^>]*>//Ig' | |
|
|
|
|
|
sed 's/^<T[DH][^>]*>\|<\/\?T[DH][^>]*>$//Ig' | |
|
|
|
|
|
sed 's/<\/T[DH][^>]*><T[DH][^>]*>/,/Ig' | |
|
|
|
|
|
grep 'edit.php?' | |
|
|
|
|
|
grep $top_domain)" |
|
|
|
|
|
|
|
|
subdomain_csv="$(echo $htmlpage \ |
|
|
|
|
|
| grep -i -e '</\?TABLE\|</\?TD\|</\?TR\|</\?TH' \ |
|
|
|
|
|
| sed 's/^[\ \t]*//g' \ |
|
|
|
|
|
| tr -d '\n' \ |
|
|
|
|
|
| sed 's/<\/TR[^>]*>/\n/Ig' \ |
|
|
|
|
|
| sed 's/<\/\?\(TABLE\|TR\)[^>]*>//Ig' \ |
|
|
|
|
|
| sed 's/^<T[DH][^>]*>\|<\/\?T[DH][^>]*>$//Ig' \ |
|
|
|
|
|
| sed 's/<\/T[DH][^>]*><T[DH][^>]*>/,/Ig' \ |
|
|
|
|
|
| grep 'edit.php?' \ |
|
|
|
|
|
| grep $top_domain)" |
|
|
# The above beauty ends with striping out rows that do not have an |
|
|
# The above beauty ends with striping out rows that do not have an |
|
|
# href to edit.php and do not have the top domain we are looking for. |
|
|
# href to edit.php and do not have the top domain we are looking for. |
|
|
# So all we should be left with is CSV of table of subdomains we are |
|
|
# So all we should be left with is CSV of table of subdomains we are |
|
@ -78,8 +77,7 @@ dns_freedns_add() { |
|
|
# 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 |
|
|
IFS=$'\n' |
|
|
IFS=$'\n' |
|
|
found=0 |
|
|
found=0 |
|
|
for line in $subdomain_csv |
|
|
|
|
|
do |
|
|
|
|
|
|
|
|
for line in $subdomain_csv; do |
|
|
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 |
|
|
# this line will contain DNSdomainid for the top_domain |
|
|
# this line will contain DNSdomainid for the top_domain |
|
@ -189,16 +187,16 @@ dns_freedns_rm() { |
|
|
|
|
|
|
|
|
# Now convert the tables in the HTML to CSV. This litte gem from |
|
|
# Now convert the tables in the HTML to CSV. This litte gem from |
|
|
# http://stackoverflow.com/questions/1403087/how-can-i-convert-an-html-table-to-csv |
|
|
# http://stackoverflow.com/questions/1403087/how-can-i-convert-an-html-table-to-csv |
|
|
subdomain_csv="$(echo $htmlpage | |
|
|
|
|
|
grep -i -e '</\?TABLE\|</\?TD\|</\?TR\|</\?TH' | |
|
|
|
|
|
sed 's/^[\ \t]*//g' | |
|
|
|
|
|
tr -d '\n' | |
|
|
|
|
|
sed 's/<\/TR[^>]*>/\n/Ig' | |
|
|
|
|
|
sed 's/<\/\?\(TABLE\|TR\)[^>]*>//Ig' | |
|
|
|
|
|
sed 's/^<T[DH][^>]*>\|<\/\?T[DH][^>]*>$//Ig' | |
|
|
|
|
|
sed 's/<\/T[DH][^>]*><T[DH][^>]*>/,/Ig' | |
|
|
|
|
|
grep 'edit.php?' | |
|
|
|
|
|
grep $fulldomain)" |
|
|
|
|
|
|
|
|
subdomain_csv="$(echo $htmlpage \ |
|
|
|
|
|
| grep -i -e '</\?TABLE\|</\?TD\|</\?TR\|</\?TH' \ |
|
|
|
|
|
| sed 's/^[\ \t]*//g' \ |
|
|
|
|
|
| tr -d '\n' \ |
|
|
|
|
|
| sed 's/<\/TR[^>]*>/\n/Ig' \ |
|
|
|
|
|
| sed 's/<\/\?\(TABLE\|TR\)[^>]*>//Ig' \ |
|
|
|
|
|
| sed 's/^<T[DH][^>]*>\|<\/\?T[DH][^>]*>$//Ig' \ |
|
|
|
|
|
| sed 's/<\/T[DH][^>]*><T[DH][^>]*>/,/Ig' \ |
|
|
|
|
|
| grep 'edit.php?' \ |
|
|
|
|
|
| grep $fulldomain)" |
|
|
# The above beauty ends with striping out rows that do not have an |
|
|
# The above beauty ends with striping out rows that do not have an |
|
|
# href to edit.php and do not have the domain name we are looking for. |
|
|
# href to edit.php and do not have the domain name we are looking for. |
|
|
# So all we should be left with is CSV of table of subdomains we are |
|
|
# So all we should be left with is CSV of table of subdomains we are |
|
@ -206,8 +204,7 @@ dns_freedns_rm() { |
|
|
|
|
|
|
|
|
# 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 |
|
|
IFS=$'\n' |
|
|
IFS=$'\n' |
|
|
for line in $subdomain_csv |
|
|
|
|
|
do |
|
|
|
|
|
|
|
|
for line in $subdomain_csv; do |
|
|
dns_href="$(echo $line | cut -d ',' -f 2)" |
|
|
dns_href="$(echo $line | cut -d ',' -f 2)" |
|
|
tmp=${dns_href#*>} |
|
|
tmp=${dns_href#*>} |
|
|
DNSname=${tmp%%<*} |
|
|
DNSname=${tmp%%<*} |
|
@ -221,7 +218,7 @@ dns_freedns_rm() { |
|
|
tmp=${tmp#"} |
|
|
tmp=${tmp#"} |
|
|
DNSvalue=${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 |
|
|
# field. So for now we will assume that there is only one TXT |
|
|
# field. So for now we will assume that there is only one TXT |
|
|
# field for the sub domain and just delete it. Currently this |
|
|
# field for the sub domain and just delete it. Currently this |
|
@ -229,7 +226,7 @@ dns_freedns_rm() { |
|
|
unset IFS |
|
|
unset IFS |
|
|
_freedns_delete_txt_record $FREEDNS_COOKIE $DNSdataid |
|
|
_freedns_delete_txt_record $FREEDNS_COOKIE $DNSdataid |
|
|
return $? |
|
|
return $? |
|
|
# fi |
|
|
|
|
|
|
|
|
# fi |
|
|
fi |
|
|
fi |
|
|
done |
|
|
done |
|
|
unset IFS |
|
|
unset IFS |
|
@ -355,11 +352,11 @@ _freedns_delete_txt_record() { |
|
|
_freedns_urlencode() { |
|
|
_freedns_urlencode() { |
|
|
# urlencode <string> |
|
|
# urlencode <string> |
|
|
length="${#1}" |
|
|
length="${#1}" |
|
|
for (( i = 0; i < length; i++ )); do |
|
|
|
|
|
|
|
|
for ((i = 0; i < length; i++)); do |
|
|
c="${1:i:1}" |
|
|
c="${1:i:1}" |
|
|
case $c in |
|
|
case $c in |
|
|
[a-zA-Z0-9.~_-]) printf "$c" ;; |
|
|
[a-zA-Z0-9.~_-]) printf "$c" ;; |
|
|
*) printf '%%%02X' "'$c" |
|
|
|
|
|
|
|
|
*) printf '%%%02X' "'$c" ;; |
|
|
esac |
|
|
esac |
|
|
done |
|
|
done |
|
|
} |
|
|
} |