[packages] ntpclient: add option to bind ntpclient to a specific interface (#6470)

git-svn-id: svn://svn.openwrt.org/openwrt/packages@19134 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
jow
2010-01-14 19:02:19 +00:00
parent 976e004951
commit fe5632be50
3 changed files with 17 additions and 2 deletions

View File

@ -20,3 +20,4 @@ config ntpdrift
config ntpclient
option interval 600
#option count 10
#option interface wan

View File

@ -7,14 +7,26 @@ unset SERVER
unset PORT
unset INTERVAL
unset COUNT
unset INTERFACE_GLOBAL
NTPC=`which ntpclient`
check_server() {
local hostname
local port
local interface
[ -n "$SERVER" ] && return
config_get hostname $1 hostname
config_get port $1 port
config_get interface $1 interface
[ -z "$interface" ] && interface=$INTERFACE_GLOBAL
[ -n "$interface" ] && {
# $INTERFACE is passed from hotplug event
[ "$interface" = "$INTERFACE" ] || return
}
[ -z "$hostname" ] && return
$NTPC -c 1 -p ${port:-123} -i 2 -h $hostname > /dev/null && { SERVER=$hostname; PORT=${port:-123}; }
}
@ -44,9 +56,11 @@ load_settings() {
config_get interval $1 interval
config_get count $1 count
config_get interface $1 interface
[ -n "$count" ] && COUNT=$count
[ -n "$interval" ] && INTERVAL=$interval
[ -n "$interface" ] && INTERFACE_GLOBAL=$interface
}
config_load ntpclient