# The TXT record might already exist when working with wildcard certificates. In that case, update the record by adding the new value.
if _constellix_rest POST "domains/${_domain_id}/records""[{\"type\":\"txt\",\"add\":true,\"set\":{\"name\":\"${_sub_domain}\",\"ttl\":120,\"roundRobin\":[{\"value\":\"${txtvalue}\"}]}}]";then
if _constellix_rest GET "domains/${_domain_id}/records/TXT/search?exact=${_sub_domain}";then
_info "Added"
if printf--"%s""$response" | grep"{\"errors\":\[\"Requested record was not found\"\]}">/dev/null;then
return 0
_info "Adding TXT record"
if _constellix_rest POST "domains/${_domain_id}/records""[{\"type\":\"txt\",\"add\":true,\"set\":{\"name\":\"${_sub_domain}\",\"ttl\":60,\"roundRobin\":[{\"value\":\"${txtvalue}\"}]}}]";then
if _constellix_rest PUT "domains/${_domain_id}/records/TXT/${_record_id}""{\"name\":\"${_sub_domain}\",\"ttl\":60,${_new_rr_values}}";then
if printf--"%s""$response" | grep"{\"success\":\"Record.*updated successfully\"}">/dev/null;then
_info "Updated"
return 0
elif printf--"%s""$response" | grep"{\"errors\":\[\"Contents are identical\"\]}">/dev/null;then
_info "Already exists, no need to update"
return 0
else
_err "Error updating TXT record"
fi
fi
fi
fi
fi
fi
fi
return 1
}
}
# Usage: fulldomain txtvalue
# Usage: fulldomain txtvalue
...
@@ -61,16 +86,26 @@ dns_constellix_rm() {
...
@@ -61,16 +86,26 @@ dns_constellix_rm() {
return 1
return 1
fi
fi
_info "Removing TXT record"
# The TXT record might have been removed already when working with some wildcard certificates.
if _constellix_rest POST "domains/${_domain_id}/records""[{\"type\":\"txt\",\"delete\":true,\"filter\":{\"field\":\"name\",\"op\":\"eq\",\"value\":\"${_sub_domain}\"}}]";then
if _constellix_rest GET "domains/${_domain_id}/records/TXT/search?exact=${_sub_domain}";then
if printf--"%s""$response" | grep"{\"errors\":\[\"Requested record was not found\"\]}">/dev/null;then
_info "Removed"
_info "Removed"
return 0
return 0
else
else
_err "Error removing TXT record"
_info "Removing TXT record"
return 1
if _constellix_rest POST "domains/${_domain_id}/records""[{\"type\":\"txt\",\"delete\":true,\"filter\":{\"field\":\"name\",\"op\":\"eq\",\"value\":\"${_sub_domain}\"}}]";then
if! _rest POST "Record.Create""login_token=$DP_Id,$DP_Key&format=json&lang=en&domain_id=$_domain_id&sub_domain=$_sub_domain&record_type=TXT&value=$txtvalue&record_line=默认";then
if! _rest POST "Record.Create""login_token=$DP_Id,$DP_Key&format=json&lang=en&domain_id=$_domain_id&sub_domain=$_sub_domain&record_type=TXT&value=$txtvalue&record_line=%E9%BB%98%E8%AE%A4";then