Avoid usage of sed -E
grep -q
and printf -v
This commit is contained in:
parent
a00169451f
commit
9a1f769828
@ -37,7 +37,7 @@ dns_inwx_add() {
|
|||||||
_debug _domain "$_domain"
|
_debug _domain "$_domain"
|
||||||
_debug "Getting txt records"
|
_debug "Getting txt records"
|
||||||
|
|
||||||
printf -v xml_content '<?xml version="1.0" encoding="UTF-8"?>
|
xml_content=$(printf '<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>nameserver.info</methodName>
|
<methodName>nameserver.info</methodName>
|
||||||
<params>
|
<params>
|
||||||
@ -66,7 +66,7 @@ dns_inwx_add() {
|
|||||||
</value>
|
</value>
|
||||||
</param>
|
</param>
|
||||||
</params>
|
</params>
|
||||||
</methodCall>' "$_domain" "$_sub_domain"
|
</methodCall>' "$_domain" "$_sub_domain")
|
||||||
response="$(_post "$xml_content" "$INWX_Api" "" "POST")"
|
response="$(_post "$xml_content" "$INWX_Api" "" "POST")"
|
||||||
|
|
||||||
if ! printf "%s" "$response" | grep "Command completed successfully" >/dev/null; then
|
if ! printf "%s" "$response" | grep "Command completed successfully" >/dev/null; then
|
||||||
@ -74,11 +74,11 @@ dns_inwx_add() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! printf "%s" "$response" | grep "count" -q; then
|
if ! printf "%s" "$response" | grep "count" >/dev/null; then
|
||||||
_info "Adding record"
|
_info "Adding record"
|
||||||
_inwx_add_record "$_domain" "$_sub_domain" "$txtvalue"
|
_inwx_add_record "$_domain" "$_sub_domain" "$txtvalue"
|
||||||
else
|
else
|
||||||
_record_id=$(printf '%s' "$response" | sed -nE 's/.*(<member><name>record){1}(.*)(<name>id<\/name><value><int>)([0-9]+){1}.*/\4/p')
|
_record_id=$(printf '%s' "$response" | _egrep_o '.*(<member><name>record){1}(.*)([0-9]+){1}' | _egrep_o '<name>id<\/name><value><int>[0-9]+' | egrep -o '[0-9]+')
|
||||||
_info "Updating record"
|
_info "Updating record"
|
||||||
_inwx_update_record "$_record_id" "$txtvalue"
|
_inwx_update_record "$_record_id" "$txtvalue"
|
||||||
fi
|
fi
|
||||||
@ -115,7 +115,7 @@ dns_inwx_rm() {
|
|||||||
|
|
||||||
_debug "Getting txt records"
|
_debug "Getting txt records"
|
||||||
|
|
||||||
printf -v xml_content '<?xml version="1.0" encoding="UTF-8"?>
|
xml_content=$(printf '<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>nameserver.info</methodName>
|
<methodName>nameserver.info</methodName>
|
||||||
<params>
|
<params>
|
||||||
@ -144,7 +144,7 @@ dns_inwx_rm() {
|
|||||||
</value>
|
</value>
|
||||||
</param>
|
</param>
|
||||||
</params>
|
</params>
|
||||||
</methodCall>' "$_domain" "$_sub_domain"
|
</methodCall>' "$_domain" "$_sub_domain")
|
||||||
response="$(_post "$xml_content" "$INWX_Api" "" "POST")"
|
response="$(_post "$xml_content" "$INWX_Api" "" "POST")"
|
||||||
|
|
||||||
if ! printf "%s" "$response" | grep "Command completed successfully" >/dev/null; then
|
if ! printf "%s" "$response" | grep "Command completed successfully" >/dev/null; then
|
||||||
@ -152,10 +152,10 @@ dns_inwx_rm() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! printf "%s" "$response" | grep "count" -q; then
|
if ! printf "%s" "$response" | grep "count" >/dev/null; then
|
||||||
_info "Do not need to delete record"
|
_info "Do not need to delete record"
|
||||||
else
|
else
|
||||||
_record_id=$(printf '%s' "$response" | sed -nE 's/.*(<member><name>record){1}(.*)(<name>id<\/name><value><int>)([0-9]+){1}.*/\4/p')
|
_record_id=$(printf '%s' "$response" | _egrep_o '.*(<member><name>record){1}(.*)([0-9]+){1}' | _egrep_o '<name>id<\/name><value><int>[0-9]+' | egrep -o '[0-9]+')
|
||||||
_info "Deleting record"
|
_info "Deleting record"
|
||||||
_inwx_delete_record "$_record_id"
|
_inwx_delete_record "$_record_id"
|
||||||
fi
|
fi
|
||||||
@ -166,7 +166,7 @@ dns_inwx_rm() {
|
|||||||
|
|
||||||
_inwx_login() {
|
_inwx_login() {
|
||||||
|
|
||||||
printf -v xml_content '<?xml version="1.0" encoding="UTF-8"?>
|
xml_content=$(printf '<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>account.login</methodName>
|
<methodName>account.login</methodName>
|
||||||
<params>
|
<params>
|
||||||
@ -189,7 +189,7 @@ _inwx_login() {
|
|||||||
</value>
|
</value>
|
||||||
</param>
|
</param>
|
||||||
</params>
|
</params>
|
||||||
</methodCall>' $INWX_User $INWX_Password
|
</methodCall>' $INWX_User $INWX_Password)
|
||||||
|
|
||||||
response="$(_post "$xml_content" "$INWX_Api" "" "POST")"
|
response="$(_post "$xml_content" "$INWX_Api" "" "POST")"
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ _get_root() {
|
|||||||
|
|
||||||
_H1=$(_inwx_login)
|
_H1=$(_inwx_login)
|
||||||
export _H1
|
export _H1
|
||||||
printf -v xml_content '<?xml version="1.0" encoding="UTF-8"?>
|
xml_content='<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>nameserver.list</methodName>
|
<methodName>nameserver.list</methodName>
|
||||||
</methodCall>'
|
</methodCall>'
|
||||||
@ -235,7 +235,7 @@ _get_root() {
|
|||||||
|
|
||||||
_inwx_delete_record() {
|
_inwx_delete_record() {
|
||||||
record_id=$1
|
record_id=$1
|
||||||
printf -v xml_content '<?xml version="1.0" encoding="UTF-8"?>
|
xml_content=$(printf '<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>nameserver.deleteRecord</methodName>
|
<methodName>nameserver.deleteRecord</methodName>
|
||||||
<params>
|
<params>
|
||||||
@ -252,7 +252,7 @@ _inwx_delete_record() {
|
|||||||
</value>
|
</value>
|
||||||
</param>
|
</param>
|
||||||
</params>
|
</params>
|
||||||
</methodCall>' "$record_id"
|
</methodCall>' "$record_id")
|
||||||
|
|
||||||
response="$(_post "$xml_content" "$INWX_Api" "" "POST")"
|
response="$(_post "$xml_content" "$INWX_Api" "" "POST")"
|
||||||
|
|
||||||
@ -267,7 +267,7 @@ _inwx_delete_record() {
|
|||||||
_inwx_update_record() {
|
_inwx_update_record() {
|
||||||
record_id=$1
|
record_id=$1
|
||||||
txtval=$2
|
txtval=$2
|
||||||
printf -v xml_content '<?xml version="1.0" encoding="UTF-8"?>
|
xml_content=$(printf '<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>nameserver.updateRecord</methodName>
|
<methodName>nameserver.updateRecord</methodName>
|
||||||
<params>
|
<params>
|
||||||
@ -290,7 +290,7 @@ _inwx_update_record() {
|
|||||||
</value>
|
</value>
|
||||||
</param>
|
</param>
|
||||||
</params>
|
</params>
|
||||||
</methodCall>' "$txtval" "$record_id"
|
</methodCall>' "$txtval" "$record_id")
|
||||||
|
|
||||||
response="$(_post "$xml_content" "$INWX_Api" "" "POST")"
|
response="$(_post "$xml_content" "$INWX_Api" "" "POST")"
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ _inwx_add_record() {
|
|||||||
sub_domain=$2
|
sub_domain=$2
|
||||||
txtval=$3
|
txtval=$3
|
||||||
|
|
||||||
printf -v xml_content '<?xml version="1.0" encoding="UTF-8"?>
|
xml_content=$(printf '<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<methodCall>
|
<methodCall>
|
||||||
<methodName>nameserver.createRecord</methodName>
|
<methodName>nameserver.createRecord</methodName>
|
||||||
<params>
|
<params>
|
||||||
@ -343,7 +343,7 @@ _inwx_add_record() {
|
|||||||
</value>
|
</value>
|
||||||
</param>
|
</param>
|
||||||
</params>
|
</params>
|
||||||
</methodCall>' "$domain" "$txtval" "$sub_domain"
|
</methodCall>' "$domain" "$txtval" "$sub_domain")
|
||||||
|
|
||||||
response="$(_post "$xml_content" "$INWX_Api" "" "POST")"
|
response="$(_post "$xml_content" "$INWX_Api" "" "POST")"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user