ddns-scripts: rename variable: s/retry_count/retry_max_count/
[feed/packages.git] / net / ddns-scripts / files / usr / lib / ddns / dynamic_dns_updater.sh
index 9e75552d9995f3b0b66459bfdddbcf8101b0bde2..47b2abfdf2462754d56d31718a8520ac0a64cec9 100644 (file)
@@ -159,7 +159,7 @@ trap "trap_handler 15" 15   # SIGTERM       Termination
 #
 # retry_interval       if error was detected retry in
 # retry_unit           'days' 'hours' 'minutes' 'seconds'
-# retry_count          number of retries before scripts stops
+# retry_max_count      number of retries before scripts stops
 #
 # use_ipv6             detecting/sending IPv6 address
 # force_ipversion      force usage of IPv4 or IPv6 for the whole detection and update communication
@@ -180,7 +180,7 @@ ERR_LAST=$? # save return code - equal 0 if SECTION_ID found
 
 # set defaults if not defined
 [ -z "$enabled" ]        && enabled=0
-[ -z "$retry_count" ]    && retry_count=0      # endless retry
+[ -z "$retry_max_count" ] && retry_max_count=0 # endless retry
 [ -z "$use_syslog" ]      && use_syslog=2      # syslog "Notice"
 [ -z "$use_https" ]       && use_https=0       # not use https
 [ -z "$use_logfile" ]     && use_logfile=1     # use logfile by default
@@ -233,7 +233,11 @@ esac
 # otherwise update_url is set inside configuration (custom update url)
 # or update_script is set inside configuration (custom update script)
 [ -n "$service_name" ] && {
-       get_service_data "$service_name" update_url update_script UPD_ANSWER
+       # Check first if we have a custom service provider with this name
+       get_service_data "$service_name" "/usr/share/ddns/custom" update_url update_script UPD_ANSWER
+       if [ "$?" != "0" ]; then
+               get_service_data "$service_name" "/usr/share/ddns/default" update_url update_script UPD_ANSWER
+       fi
 }
 
 [ -z "$update_url" -a -z "$update_script" ] && write_log 14 "No update_url found/defined or no update_script found/defined!"
@@ -253,7 +257,7 @@ esac
 # verify validity of variables
 [ -n "$lookup_host" ] && sanitize_variable lookup_host "$DNS_CHARSET" ""
 [ -n "$dns_server" ] && sanitize_variable dns_server "$DNS_CHARSET" ""
-[ -n "$domain" ] && sanitize_variable domain "$DNS_CHARSET" ""
+[ -n "$domain" ] && sanitize_variable domain "$DNS_CHARSET_DOMAIN" ""
 
 # Filter shell escape characters, if these are required in the URL, they
 # can still be passed url encoded
@@ -289,7 +293,7 @@ get_seconds RETRY_SECONDS ${retry_interval:-60} ${retry_unit:-"seconds"} # defau
 write_log 7 "check interval: $CHECK_SECONDS seconds"
 write_log 7 "force interval: $FORCE_SECONDS seconds"
 write_log 7 "retry interval: $RETRY_SECONDS seconds"
-write_log 7 "retry counter : $retry_count times"
+write_log 7 "retry max count : $retry_max_count times"
 
 # kill old process if it exists & set new pid file
 stop_section_processes "$SECTION_ID"
@@ -408,9 +412,9 @@ while : ; do
        if [ "$LOCAL_IP" != "$REGISTERED_IP" ]; then
                if [ $VERBOSE -le 1 ]; then     # VERBOSE <=1 then retry
                        ERR_UPDATE=$(( $ERR_UPDATE + 1 ))
-                       [ $retry_count -gt 0 -a $ERR_UPDATE -gt $retry_count ] && \
-                               write_log 14 "Updating IP at DDNS provider failed after $retry_count retries"
-                       write_log 4 "Updating IP at DDNS provider failed - starting retry $ERR_UPDATE/$retry_count"
+                       [ $retry_max_count -gt 0 -a $ERR_UPDATE -gt $retry_max_count ] && \
+                               write_log 14 "Updating IP at DDNS provider failed after $retry_max_count retries"
+                       write_log 4 "Updating IP at DDNS provider failed - starting retry $ERR_UPDATE/$retry_max_count"
                        continue # loop to beginning
                else
                        write_log 4 "Updating IP at DDNS provider failed"