Fix DNS API scripts on *BSD

\n isn't available in all regex/sed
This commit is contained in:
Jeremy Knope 2017-07-26 09:44:11 -04:00
parent a6a0495392
commit 29b21b828b
5 changed files with 16 additions and 8 deletions

View File

@ -92,7 +92,8 @@ _get_root() {
p=1 p=1
if _ad_rest GET "domain/"; then if _ad_rest GET "domain/"; then
response="$(echo "$response" | tr -d "\n" | sed 's/{/\n&/g')" response="$(echo "$response" | tr -d "\n" | sed 's/{/\
&/g')"
while true; do while true; do
h=$(printf "%s" "$domain" | cut -d . -f $i-100) h=$(printf "%s" "$domain" | cut -d . -f $i-100)
_debug h "$h" _debug h "$h"

View File

@ -69,9 +69,11 @@ _dns_do_list_rrs() {
fi fi
_rr_list="$(echo "${response}" \ _rr_list="$(echo "${response}" \
| tr -d "\n\r\t" \ | tr -d "\n\r\t" \
| sed -e 's/<item xsi:type="ns2:Map">/\n/g' \ | sed -e 's/<item xsi:type="ns2:Map">/\
/g' \
| grep ">$(_regexcape "$fulldomain")</value>" \ | grep ">$(_regexcape "$fulldomain")</value>" \
| sed -e 's/<\/item>/\n/g' \ | sed -e 's/<\/item>/\
/g' \
| grep '>id</key><value' \ | grep '>id</key><value' \
| _egrep_o '>[0-9]{1,16}<' \ | _egrep_o '>[0-9]{1,16}<' \
| tr -d '><')" | tr -d '><')"

View File

@ -77,7 +77,8 @@ dns_freedns_add() {
| grep -i -e '</\?TABLE\|</\?TD\|</\?TR\|</\?TH' \ | grep -i -e '</\?TABLE\|</\?TD\|</\?TR\|</\?TH' \
| sed 's/^[\ \t]*//g' \ | sed 's/^[\ \t]*//g' \
| tr -d '\n' \ | tr -d '\n' \
| sed 's/<\/TR[^>]*>/\n/Ig' \ | sed 's/<\/TR[^>]*>/\
/Ig' \
| sed 's/<\/\?\(TABLE\|TR\)[^>]*>//Ig' \ | sed 's/<\/\?\(TABLE\|TR\)[^>]*>//Ig' \
| sed 's/^<T[DH][^>]*>\|<\/\?T[DH][^>]*>$//Ig' \ | sed 's/^<T[DH][^>]*>\|<\/\?T[DH][^>]*>$//Ig' \
| sed 's/<\/T[DH][^>]*><T[DH][^>]*>/,/Ig' \ | sed 's/<\/T[DH][^>]*><T[DH][^>]*>/,/Ig' \
@ -216,7 +217,8 @@ dns_freedns_rm() {
| grep -i -e '</\?TABLE\|</\?TD\|</\?TR\|</\?TH' \ | grep -i -e '</\?TABLE\|</\?TD\|</\?TR\|</\?TH' \
| sed 's/^[\ \t]*//g' \ | sed 's/^[\ \t]*//g' \
| tr -d '\n' \ | tr -d '\n' \
| sed 's/<\/TR[^>]*>/\n/Ig' \ | sed 's/<\/TR[^>]*>/\
/Ig' \
| sed 's/<\/\?\(TABLE\|TR\)[^>]*>//Ig' \ | sed 's/<\/\?\(TABLE\|TR\)[^>]*>//Ig' \
| sed 's/^<T[DH][^>]*>\|<\/\?T[DH][^>]*>$//Ig' \ | sed 's/^<T[DH][^>]*>\|<\/\?T[DH][^>]*>$//Ig' \
| sed 's/<\/T[DH][^>]*><T[DH][^>]*>/,/Ig' \ | sed 's/<\/T[DH][^>]*><T[DH][^>]*>/,/Ig' \

View File

@ -68,7 +68,8 @@ dns_linode_rm() {
_parameters="&DomainID=$_domain_id" _parameters="&DomainID=$_domain_id"
if _rest GET "domain.resource.list" "$_parameters" && [ -n "$response" ]; then if _rest GET "domain.resource.list" "$_parameters" && [ -n "$response" ]; then
response="$(echo "$response" | tr -d "\n" | sed 's/{/\n&/g')" response="$(echo "$response" | tr -d "\n" | sed 's/{/\
&/g')"
resource="$(echo "$response" | _egrep_o "{.*\"NAME\":\s*\"$_sub_domain\".*}")" resource="$(echo "$response" | _egrep_o "{.*\"NAME\":\s*\"$_sub_domain\".*}")"
if [ "$resource" ]; then if [ "$resource" ]; then
@ -128,7 +129,8 @@ _get_root() {
p=1 p=1
if _rest GET "domain.list"; then if _rest GET "domain.list"; then
response="$(echo "$response" | tr -d "\n" | sed 's/{/\n&/g')" response="$(echo "$response" | tr -d "\n" | sed 's/{/\
&/g')"
while true; do while true; do
h=$(printf "%s" "$domain" | cut -d . -f $i-100) h=$(printf "%s" "$domain" | cut -d . -f $i-100)
_debug h "$h" _debug h "$h"

View File

@ -93,7 +93,8 @@ _get_root() {
p=1 p=1
if _vscale_rest GET "domains/"; then if _vscale_rest GET "domains/"; then
response="$(echo "$response" | tr -d "\n" | sed 's/{/\n&/g')" response="$(echo "$response" | tr -d "\n" | sed 's/{/\
&/g')"
while true; do while true; do
h=$(printf "%s" "$domain" | cut -d . -f $i-100) h=$(printf "%s" "$domain" | cut -d . -f $i-100)
_debug h "$h" _debug h "$h"