Fix the hotplug script and add a kakikaze config file (#1083)
authorFlorian Fainelli <florian@openwrt.org>
Tue, 10 Apr 2007 10:58:00 +0000 (10:58 +0000)
committerFlorian Fainelli <florian@openwrt.org>
Tue, 10 Apr 2007 10:58:00 +0000 (10:58 +0000)
SVN-Revision: 6920

net/openntpd/files/ntpd.config [new file with mode: 0644]
net/openntpd/files/ntpd.hotplug

diff --git a/net/openntpd/files/ntpd.config b/net/openntpd/files/ntpd.config
new file mode 100644 (file)
index 0000000..192ae7b
--- /dev/null
@@ -0,0 +1,3 @@
+config timezone
+       option posixtz "CET-1CEST,M3.5.0,M10.5.0/3"
+       option zoneinfo "Europe/Paris"
index f165e6b21e3ae2483c7e760732e7c2b661b2d45c..1b8f1dad7dc162ee60e636a7699b3ea988b860d3 100644 (file)
@@ -2,9 +2,33 @@ NAME=ntpd
 CONFIG=/etc/$NAME.conf
 COMMAND=/usr/sbin/$NAME
 
-[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && {
-        [ -x $COMMAND ] && [ -r $CONFIG ] && {
-               killall ntpd
-               /etc/init.d/ntpd start
-        } &
+. /etc/functions.sh
+
+config_cb() {
+        local cfg="$CONFIG_SECTION"
+        local cfgtype
+        config_get cfgtype "$cfg" TYPE
+
+        case "$cfgtype" in
+                timezone)
+                        config_get posixtz      $cfg posixtz
+                        config_get zoneinfo     $cfg zoneinfo
+
+                        ps x | grep 'ntpd' >&- || {
+                                route -n 2>&- | grep '^0.0.0.0' >&- && {
+                                        echo "$posixtz" > /etc/TZ
+                                       /etc/init.d/ntpd start
+                                }
+                        }
+                ;;
+        esac
 }
+
+case "${ACTION:-ifup}" in
+        ifup)
+                config_load timezone&
+        ;;
+        ifdown)
+                route -n 2>&- | grep '^0.0.0.0' >&- || /etc/init.d/ntpd stop 2>&- >&-
+        ;;
+esac