|
|
@ -59,13 +59,13 @@ dns_qc_add() { |
|
|
# count=$(printf "%s\n" "$response" | _egrep_o "\"count\":[^,]*" | cut -d : -f 2) |
|
|
# count=$(printf "%s\n" "$response" | _egrep_o "\"count\":[^,]*" | cut -d : -f 2) |
|
|
# _debug count "$count" |
|
|
# _debug count "$count" |
|
|
# if [ "$count" = "0" ]; then |
|
|
# if [ "$count" = "0" ]; then |
|
|
_info "Adding record" |
|
|
|
|
|
|
|
|
_info "Adding txt record" |
|
|
if _qc_rest POST "zones/$_domain_id/records" "{\"type\":\"TXT\",\"name\":\"$fulldomain\",\"content\":\"$txtvalue\",\"ttl\":1800}"; then |
|
|
if _qc_rest POST "zones/$_domain_id/records" "{\"type\":\"TXT\",\"name\":\"$fulldomain\",\"content\":\"$txtvalue\",\"ttl\":1800}"; then |
|
|
if _contains "$response" "$txtvalue"; then |
|
|
if _contains "$response" "$txtvalue"; then |
|
|
_info "Added, OK" |
|
|
|
|
|
|
|
|
_info "Added txt record, OK" |
|
|
return 0 |
|
|
return 0 |
|
|
elif _contains "$response" "Same record already exists"; then |
|
|
elif _contains "$response" "Same record already exists"; then |
|
|
_info "Already exists, OK" |
|
|
|
|
|
|
|
|
_info "txt record already exists, OK" |
|
|
return 0 |
|
|
return 0 |
|
|
else |
|
|
else |
|
|
_err "Add txt record error: $response" |
|
|
_err "Add txt record error: $response" |
|
|
@ -103,18 +103,19 @@ dns_qc_rm() { |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
|
|
|
|
|
|
response=$(echo "$response"|jq ".result[]" | select(.content == \"$txtvalue\") | select(.type == \"TXT\")) |
|
|
|
|
|
|
|
|
response=$(echo "$response"|jq ".result[] | select(.id) | select(.content == \"$txtvalue\") | select(.type == \"TXT\")") |
|
|
|
|
|
_debug get txt response "$response" |
|
|
if [ "${response}" = "" ]; then |
|
|
if [ "${response}" = "" ]; then |
|
|
_info "Don't need to remove." |
|
|
|
|
|
|
|
|
_info "Don't need to remove txt records." |
|
|
else |
|
|
else |
|
|
record_id=$(echo "$response" | grep \"id\"| awk -F ' ' '{print $2}'| sed 's/,$//') |
|
|
record_id=$(echo "$response" | grep \"id\"| awk -F ' ' '{print $2}'| sed 's/,$//') |
|
|
_debug "record_id" "$record_id" |
|
|
|
|
|
|
|
|
_debug "txt record_id" "$record_id" |
|
|
if [ -z "$record_id" ]; then |
|
|
if [ -z "$record_id" ]; then |
|
|
_err "Can not get record id to remove." |
|
|
|
|
|
|
|
|
_err "Can not get txt record id to remove." |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
if ! _qc_rest DELETE "zones/$_domain_id/records/$record_id"; then |
|
|
if ! _qc_rest DELETE "zones/$_domain_id/records/$record_id"; then |
|
|
_err "Delete record error." |
|
|
|
|
|
|
|
|
_err "Delete txt record error." |
|
|
return 1 |
|
|
return 1 |
|
|
fi |
|
|
fi |
|
|
_info "TXT Record ID: $record_id successfully deleted" |
|
|
_info "TXT Record ID: $record_id successfully deleted" |
|
|
|