ddns-scripts: update_gandi_net: improve logging & add timeout
authorPyry Kontio <redacted>
Mon, 28 Nov 2022 15:15:47 +0000 (00:15 +0900)
committerPyry Kontio <redacted>
Fri, 9 Dec 2022 18:37:19 +0000 (03:37 +0900)
- Improved logging
  - Log the executed curl command to be able to rerun and test it manually
  - Log the curl exit status
- Added 30 second timeout timeout for clear-cut detection of flaky connections.

Signed-off-by: Pyry Kontio <redacted>
net/ddns-scripts/Makefile
net/ddns-scripts/files/usr/lib/ddns/update_gandi_net.sh

index 8c51476c303200db5e639c4fde216560a74804c8..f5a264e3cb790e0b62701919b621c47309102702 100644 (file)
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ddns-scripts
 PKG_VERSION:=2.8.2
-PKG_RELEASE:=29
+PKG_RELEASE:=30
 
 PKG_LICENSE:=GPL-2.0
 
index 8953072e437ba46b3c535cc7420f8e6b1a41e617..321687d7007675f62e4c0af63381cb166b2da27b 100644 (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)"
git clone https://git.99rst.org/PROJECT