|
|
@ -30,19 +30,8 @@ dns_zone_add() { |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
_debug "Getting txt records" |
|
|
|
|
|
_debug _domain "$_domain" |
|
|
|
|
|
|
|
|
|
|
|
_zone_rest GET "dns/${_domain}/txt" |
|
|
|
|
|
|
|
|
|
|
|
if printf "%s" "$response" | grep \"error\" >/dev/null; then |
|
|
|
|
|
_err "Error" |
|
|
|
|
|
return 1 |
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
_debug "Adding txt record" |
|
|
|
|
|
|
|
|
count=$(printf "%s\n" "$response" | _egrep_o "\"name\":\"$fulldomain\"" | wc -l) |
|
|
|
|
|
_debug count "$count" |
|
|
|
|
|
if [ "$count" = "0" ]; then |
|
|
|
|
|
if _zone_rest POST "dns/${_domain}/txt" "{\"name\": \"$fulldomain\", \"destination\": \"$txtvalue\"}"; then |
|
|
if _zone_rest POST "dns/${_domain}/txt" "{\"name\": \"$fulldomain\", \"destination\": \"$txtvalue\"}"; then |
|
|
if printf -- "%s" "$response" | grep "$fulldomain" >/dev/null; then |
|
|
if printf -- "%s" "$response" | grep "$fulldomain" >/dev/null; then |
|
|
_info "Added, OK" |
|
|
_info "Added, OK" |
|
|
@ -51,18 +40,8 @@ dns_zone_add() { |
|
|
_err "Adding txt record error." |
|
|
_err "Adding txt record error." |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
fi |
|
|
|
|
|
_err "Adding txt record error." |
|
|
|
|
|
else |
|
|
else |
|
|
_info "Updating record" |
|
|
|
|
|
record_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":\"[^\"]*\",\"resource_url\":\"[^\"]*\",\"name\":\"$fulldomain\"," | cut -d : -f4 | cut -d , -f1 | tr -d \" | head -n 1) |
|
|
|
|
|
_zone_rest PUT "dns/${_domain}/txt/$record_id" "{\"name\": \"$fulldomain\", \"destination\": \"$txtvalue\"}" |
|
|
|
|
|
if [ "$?" = "0" ]; then |
|
|
|
|
|
_info "Updated, OK" |
|
|
|
|
|
return 0 |
|
|
|
|
|
fi |
|
|
|
|
|
_err "Update error" |
|
|
|
|
|
return 1 |
|
|
|
|
|
|
|
|
_err "Adding txt record error." |
|
|
fi |
|
|
fi |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|