Add ntpclient config files by Carlos Sobrinho, thanks ! (#1052)
[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 config_get count $cfg count
16
17 ps x | grep 'bin/[n]tpclient' >&- || {
18 route -n 2>&- | grep '^0.0.0.0' >&- && {
19 /usr/sbin/ntpclient -c ${count:-1} -s -h $hostname -p ${port:-123} 2>&- >&-
20 }
21 }
22 ;;
23 esac
24 }
25 case "${ACTION:-ifup}" in
26 ifup)
27 config_load ntp_client&
28 ;;
29 ifdown)
30 route -n 2>&- | grep '^0.0.0.0' >&- || killall ntpclient 2>&- >&-
31 ;;
32 esac