6
6
# Create a dynadot api key under the web portal "Tools > API" and export that for this script:
7
7
# export DYNADOTAPI_Token="ASDF1234ASDF1234"
8
8
#
9
+ # export DYNADOTAPI_API_RETRIES=1 (optional) Number of times to attempt Dynadot API call until success (default=1)
10
+ # export DYNADOTAPI_RETRY_SLEEP=30 (optional) Seconds to sleep between retry attempts (default: 30 seconds)
11
+ #
9
12
# Important notes:
10
13
# At the time of writing this integration, there are some quirks with the Dynadot APIs:
11
14
#
@@ -50,10 +53,21 @@ dns_dynadot_add() {
50
53
_err " Please create your token and try again."
51
54
return 1
52
55
fi
53
-
54
56
# save the credentials to the account conf file.
55
57
_saveaccountconf_mutable DYNADOTAPI_Token " $DYNADOTAPI_Token "
56
58
59
+ DYNADOTAPI_API_RETRIES=" ${DYNADOTAPI_API_RETRIES:- $(_readaccountconf_mutable DYNADOTAPI_API_RETRIES)} "
60
+ if [ -z " $DYNADOTAPI_API_RETRIES " ]; then
61
+ DYNADOTAPI_API_RETRIES=1
62
+ fi
63
+ _saveaccountconf_mutable DYNADOTAPI_API_RETRIES " $DYNADOTAPI_API_RETRIES "
64
+
65
+ DYNADOTAPI_RETRY_SLEEP=" ${DYNADOTAPI_RETRY_SLEEP:- $(_readaccountconf_mutable DYNADOTAPI_RETRY_SLEEP)} "
66
+ if [ -z " $DYNADOTAPI_RETRY_SLEEP " ]; then
67
+ DYNADOTAPI_RETRY_SLEEP=30
68
+ fi
69
+ _saveaccountconf_mutable DYNADOTAPI_RETRY_SLEEP " $DYNADOTAPI_RETRY_SLEEP "
70
+
57
71
_debug " DYNADOT: Detecting root domain"
58
72
if ! _get_root " $fulldomain " ; then
59
73
_err " invalid domain"
@@ -83,6 +97,11 @@ dns_dynadot_add() {
83
97
return 1
84
98
fi
85
99
100
+ if [ " $DYNADOTAPI_TEST_SLEEP " ]; then
101
+ _debug " DYNADOT: Test Mode. Sleeping $DYNADOTAPI_TEST_SLEEP seconds."
102
+ sleep " $DYNADOTAPI_TEST_SLEEP "
103
+ fi
104
+
86
105
_info " DYNADOT: TXT record added successfully"
87
106
return 0
88
107
}
@@ -93,6 +112,11 @@ dns_dynadot_rm() {
93
112
fulldomain=$1
94
113
txtvalue=$2
95
114
115
+ if [ " $DYNADOTAPI_SKIP_REMOVE " = " SKIP" ]; then
116
+ _debug " DYNADOT: Skipping removal. Please remove manually."
117
+ return 0
118
+ fi
119
+
96
120
_info " DYNADOT: Removing TXT Record"
97
121
_debug " DYNADOT: fulldomain: $fulldomain "
98
122
_debug " DYNADOT: txtvalue: $txtvalue "
@@ -344,6 +368,32 @@ _dynadot_rm_txt_entry() {
344
368
345
369
_dynadot_rest () {
346
370
url_params=$1
371
+
372
+ _retry_attempts=" $DYNADOTAPI_API_RETRIES "
373
+ _retry_sleep=" $DYNADOTAPI_RETRY_SLEEP "
374
+
375
+ while true ; do
376
+ if _dynadot_rest_call " $url_params " ; then
377
+ return 0
378
+ fi
379
+
380
+ _retry_attempts=$( _math " $_retry_attempts " - 1)
381
+
382
+ if [ " ${_retry_attempts} " -lt " 1" ]; then
383
+ _err " DYNADOT: api call failed all retry attempts."
384
+ return 1
385
+ fi
386
+
387
+ _info " DYNADOT: api call failed. Retrying up to $_retry_attempts times. Sleeping $_retry_sleep seconds before retry."
388
+ sleep " $_retry_sleep "
389
+ done
390
+
391
+ # We should not get to the bottom of this function
392
+ return 1
393
+ }
394
+
395
+ _dynadot_rest_call () {
396
+ url_params=$1
347
397
token_trimmed=$( echo " $DYNADOTAPI_Token " | tr -d ' "' )
348
398
349
399
_debug " DYNADOT: Calling dynadot API: $url_params "
0 commit comments