ntpclient: add option to bind ntpclient to a specific interface (#6470)
authorJo-Philipp Wich <jow@openwrt.org>
Thu, 14 Jan 2010 19:02:19 +0000 (19:02 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Thu, 14 Jan 2010 19:02:19 +0000 (19:02 +0000)
SVN-Revision: 19134

net/ntpclient/Makefile
net/ntpclient/files/ntpclient.config
net/ntpclient/files/ntpclient.hotplug

index f2ceae9c4ccf7ca37793e11c07e43c7682f8d533..6f7d0b8b8ce638b0cd19725d226b43b994b259db 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2006-2009 OpenWrt.org
+# Copyright (C) 2006-2010 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=ntpclient
 PKG_VERSION:=2007_365
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=http://doolittle.icarus.com/ntpclient/
index c1402578f10d37db78166e0ac7068b67d17b933a..10be886263565aece5c5b7344e3f1c1db97c515c 100644 (file)
@@ -20,3 +20,4 @@ config ntpdrift
 config ntpclient
        option interval 600
        #option count   10
+       #option interface wan
index 7399264d153744e3ba1b4d6a59abd5af996db009..c932688c9a951233d36ea6d6c6c75aaec3d168f4 100644 (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