Fix count/clock setting arguments (#1527)
[openwrt/svn-archive/archive.git] / net / ntpclient / files / ntpclient.init
1 #!/bin/sh
2 # Copyright (C) 2006 OpenWrt.org
3
4 . /etc/functions.sh
5
6 config_cb() {
7 local cfg="$CONFIG_SECTION"
8 local cfgtype
9 config_get cfgtype "$cfg" TYPE
10
11 case "$cfgtype" in
12 ntp_client)
13 config_get hostname $cfg hostname
14 config_get port $cfg port
15
16 ps x | grep 'bin/[n]tpclient' >&- || {
17 route -n 2>&- | grep '^0.0.0.0' >&- && {
18 /usr/sbin/ntpclient -s -h $hostname -p ${port:-123} 2>&- >&-
19 }
20 }
21 ;;
22 esac
23 }
24 case "${ACTION:-ifup}" in
25 ifup)
26 config_load ntp_client&
27 ;;
28 ifdown)
29 route -n 2>&- | grep '^0.0.0.0' >&- || killall ntpclient 2>&- >&-
30 ;;
31 esac