Skip to content

Commit e6e05d2

Browse files
Tim Flubshifeckert
authored andcommitted
ddns-scripts: netcup.com adjust update error path
Adjust the update error handling path to avoid hard failures on recoverable errors. This allows ddns to retry updates after the configured retry interval and improves reliability. Signed-off-by: Tim Flubshi <flubshi@gmail.com>
1 parent bd6a551 commit e6e05d2

2 files changed

Lines changed: 28 additions & 12 deletions

File tree

net/ddns-scripts/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
88

99
PKG_NAME:=ddns-scripts
1010
PKG_VERSION:=2.8.3
11-
PKG_RELEASE:=2
11+
PKG_RELEASE:=3
1212

1313
PKG_LICENSE:=GPL-2.0
1414

net/ddns-scripts/files/usr/lib/ddns/update_netcup_com.sh

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,10 @@ netcup_check_response() {
134134

135135
if [ "$__status" != "success" ]; then
136136
json_cleanup
137-
write_log 14 "netcup DDNS: $__context failed (status='$__status' code=$__statuscode): $__shortmsg"
137+
write_log 3 "netcup DDNS: $__context failed (status='$__status' code=$__statuscode): $__shortmsg"
138+
return 1
138139
fi
140+
return 0
139141
}
140142

141143
# ---------------------------------------------------------------------------
@@ -154,16 +156,21 @@ json_add_object "param"
154156
json_add_string "apipassword" "$password"
155157
json_close_object
156158

157-
netcup_post || write_log 14 "netcup DDNS: HTTP request failed during login"
158-
netcup_check_response "login"
159+
if ! netcup_post; then
160+
write_log 3 "netcup DDNS: HTTP request failed during login"
161+
return 1
162+
fi
163+
netcup_check_response "login" || return 1
159164

160165
json_select "responsedata"
161166
json_get_var __SESSION_ID "apisessionid"
162167
json_select ".."
163168
json_cleanup
164169

165-
[ -z "$__SESSION_ID" ] && \
166-
write_log 14 "netcup DDNS: login succeeded but no session ID was returned"
170+
if [ -z "$__SESSION_ID" ]; then
171+
write_log 3 "netcup DDNS: login succeeded but no session ID was returned"
172+
return 1
173+
fi
167174

168175
write_log 6 "netcup DDNS: login successful"
169176

@@ -178,8 +185,11 @@ json_add_object "param"
178185
json_add_string "apisessionid" "$__SESSION_ID"
179186
json_close_object
180187

181-
netcup_post || write_log 14 "netcup DDNS: HTTP request failed during infoDnsRecords"
182-
netcup_check_response "infoDnsRecords"
188+
if ! netcup_post; then
189+
write_log 3 "netcup DDNS: HTTP request failed during infoDnsRecords"
190+
return 1
191+
fi
192+
netcup_check_response "infoDnsRecords" || return 1
183193

184194
# --- Step 3: Find the record matching our hostname and type ----------------
185195
#
@@ -216,8 +226,10 @@ done
216226

217227
json_cleanup
218228

219-
[ -z "$__MATCH_ID" ] && \
220-
write_log 14 "netcup DDNS: no [$__RRTYPE] record found for hostname '$__REC_HOSTNAME' in zone '$__ZONE'"
229+
if [ -z "$__MATCH_ID" ]; then
230+
write_log 3 "netcup DDNS: no [$__RRTYPE] record found for hostname '$__REC_HOSTNAME' in zone '$__ZONE'"
231+
return 1
232+
fi
221233

222234
# --- Step 4: Update the matched record with the new IP ---------------------
223235

@@ -242,8 +254,12 @@ json_add_object "param"
242254
json_close_object
243255
json_close_object
244256

245-
netcup_post || write_log 14 "netcup DDNS: HTTP request failed during updateDnsRecords"
246-
netcup_check_response "updateDnsRecords"
257+
if ! netcup_post; then
258+
write_log 3 "netcup DDNS: HTTP request failed during updateDnsRecords"
259+
return 1
260+
fi
261+
262+
netcup_check_response "updateDnsRecords" || return 1
247263
json_cleanup
248264

249265
write_log 6 "netcup DDNS: '$__REC_HOSTNAME.$__ZONE' [$__RRTYPE] updated to $__IP"

0 commit comments

Comments
 (0)