Merge pull request #19982 from golddranks/master

ddns-scripts: update_gandi_net: improve logging & add timeout
This commit is contained in:
Tianling Shen 2022-12-13 03:59:46 +08:00 committed by GitHub
commit f7b73bf000
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 2 deletions

View File

@ -20,14 +20,23 @@ json_add_array rrset_values
json_add_string "" "$__IP"
json_close_array
# Log the curl command
write_log 7 "curl -s -X PUT \"$__ENDPOINT/domains/$domain/records/$username/$__RRTYPE\" \
-H \"Authorization: Apikey $password\" \
-H \"Content-Type: application/json\" \
-d \"$(json_dump)\" \
--connect-timeout 30"
__STATUS=$(curl -s -X PUT "$__ENDPOINT/domains/$domain/records/$username/$__RRTYPE" \
-H "Authorization: Apikey $password" \
-H "Content-Type: application/json" \
-d "$(json_dump)" \
--connect-timeout 30 \
-w "%{http_code}\n" -o $DATFILE 2>$ERRFILE)
if [ $? -ne 0 ]; then
write_log 14 "Curl failed: $(cat $ERRFILE)"
local __ERRNO=$?
if [ $__ERRNO -ne 0 ]; then
write_log 14 "Curl failed with $__ERRNO: $(cat $ERRFILE)"
return 1
elif [ -z $__STATUS ] || [ $__STATUS != 201 ]; then
write_log 14 "LiveDNS failed: $__STATUS \ngandi.net answered: $(cat $DATFILE)"