[packages] ddns-scripts: Introduce retry_interval option to periodically retry DDNS update, if it fails (#10848)
git-svn-id: svn://svn.openwrt.org/openwrt/packages@29977 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
@ -48,14 +48,16 @@
|
|||||||
# it) and how often we need to force an update ( many services
|
# it) and how often we need to force an update ( many services
|
||||||
# will expire your domain if you don't connect and do an update
|
# will expire your domain if you don't connect and do an update
|
||||||
# every so often). Use the "check_interval" to specify how
|
# every so often). Use the "check_interval" to specify how
|
||||||
# often to check whether an update is necessary, and the
|
# often to check whether an update is necessary, the "retry_interval"
|
||||||
# "force_interval" option to specify how often to force an
|
# to specify how often to retry in case the update has failed, and
|
||||||
# update. Specify the units for these values with the "check_unit"
|
# the "force_interval" option to specify how often to force an
|
||||||
# and the "force_unit" options. Units can be "days", "hours",
|
# update. Specify the units for these values with the "check_unit",
|
||||||
# "minutes" or "seconds". The default force_unit is hours and the
|
# the "retry_init" and the "force_unit" options. Units can be
|
||||||
# default check_unit is seconds. The default check_interval is
|
# "days", "hours", "minutes" or "seconds". The default force_unit
|
||||||
# 600 seconds, or ten minutes. The default force_interval is
|
# is hours, the default retry_unit is seconds and the default
|
||||||
# 72 hours or 3 days.
|
# check_unit is seconds. The default check_interval is 600 seconds,
|
||||||
|
# or ten minutes. The default retry_interval is 60 seconds, or one
|
||||||
|
# minute. The default force_interval is 72 hours or 3 days.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#########################################################
|
#########################################################
|
||||||
@ -77,6 +79,8 @@ config service "myddns"
|
|||||||
option force_unit "hours"
|
option force_unit "hours"
|
||||||
option check_interval "10"
|
option check_interval "10"
|
||||||
option check_unit "minutes"
|
option check_unit "minutes"
|
||||||
|
option retry_interval "60"
|
||||||
|
option retry_unit "seconds"
|
||||||
|
|
||||||
#option ip_source "interface"
|
#option ip_source "interface"
|
||||||
#option ip_interface "eth0.1"
|
#option ip_interface "eth0.1"
|
||||||
|
@ -68,6 +68,11 @@ then
|
|||||||
check_interval=600
|
check_interval=600
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$retry_interval" ]
|
||||||
|
then
|
||||||
|
retry_interval=60
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$check_unit" ]
|
if [ -z "$check_unit" ]
|
||||||
then
|
then
|
||||||
check_unit="seconds"
|
check_unit="seconds"
|
||||||
@ -203,6 +208,28 @@ esac
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#compute retry interval in seconds
|
||||||
|
case "$retry_unit" in
|
||||||
|
"days" )
|
||||||
|
retry_interval_seconds=$(($retry_interval*60*60*24))
|
||||||
|
;;
|
||||||
|
"hours" )
|
||||||
|
retry_interval_seconds=$(($retry_interval*60*60))
|
||||||
|
;;
|
||||||
|
"minutes" )
|
||||||
|
retry_interval_seconds=$(($retry_interval*60))
|
||||||
|
;;
|
||||||
|
"seconds" )
|
||||||
|
retry_interval_seconds=$retry_interval
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
#default is seconds
|
||||||
|
retry_interval_seconds=$retry_interval
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
verbose_echo "force seconds = $force_interval_seconds"
|
verbose_echo "force seconds = $force_interval_seconds"
|
||||||
verbose_echo "check seconds = $check_interval_seconds"
|
verbose_echo "check seconds = $check_interval_seconds"
|
||||||
|
|
||||||
@ -289,6 +316,12 @@ do
|
|||||||
|
|
||||||
#here we actually connect, and perform the update
|
#here we actually connect, and perform the update
|
||||||
update_output=$( $retrieve_prog "$final_url" )
|
update_output=$( $retrieve_prog "$final_url" )
|
||||||
|
if [ $? -gt 0 ]
|
||||||
|
then
|
||||||
|
verbose_echo "update failed"
|
||||||
|
sleep $retry_interval_seconds
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
verbose_echo "Update Output:"
|
verbose_echo "Update Output:"
|
||||||
verbose_echo "$update_output"
|
verbose_echo "$update_output"
|
||||||
|
Reference in New Issue
Block a user