Fix the hotplug script and add a kakikaze config file (#1083)
[openwrt/svn-archive/archive.git] / net / openntpd / files / ntpd.hotplug
1 NAME=ntpd
2 CONFIG=/etc/$NAME.conf
3 COMMAND=/usr/sbin/$NAME
4
5 . /etc/functions.sh
6
7 config_cb() {
8 local cfg="$CONFIG_SECTION"
9 local cfgtype
10 config_get cfgtype "$cfg" TYPE
11
12 case "$cfgtype" in
13 timezone)
14 config_get posixtz $cfg posixtz
15 config_get zoneinfo $cfg zoneinfo
16
17 ps x | grep 'ntpd' >&- || {
18 route -n 2>&- | grep '^0.0.0.0' >&- && {
19 echo "$posixtz" > /etc/TZ
20 /etc/init.d/ntpd start
21 }
22 }
23 ;;
24 esac
25 }
26
27 case "${ACTION:-ifup}" in
28 ifup)
29 config_load timezone&
30 ;;
31 ifdown)
32 route -n 2>&- | grep '^0.0.0.0' >&- || /etc/init.d/ntpd stop 2>&- >&-
33 ;;
34 esac