[packages] ntpclient: redirect adjtimex output to eliminate syslog spam. Closes ...
[openwrt/svn-archive/archive.git] / net / ntpclient / files / ntpclient.hotplug
1 #!/bin/sh
2 # Copyright (C) 2006 OpenWrt.org
3
4 . /etc/functions.sh
5
6 DONE=0
7 config_cb() {
8 local cfg="$CONFIG_SECTION"
9 local cfgtype
10 config_get cfgtype "$cfg" TYPE
11
12 # initial frequency offset, if configured
13 case "$cfgtype" in
14 ntpdrift)
15 config_get freq $cfg freq
16
17 if [ ! "$freq" = "" ]; then
18 adjtimex -f $freq >/dev/null
19 fi
20 ;;
21 esac
22
23 case "$cfgtype" in
24 ntpclient)
25 config_get hostname $cfg hostname
26 config_get port $cfg port
27 config_get count $cfg count
28
29 [ "$DONE" = "1" ] && exit 0
30 ps | grep 'bin/[n]tpclient' >&- || {
31 route -n 2>&- | grep '^0.0.0.0' >&- && {
32 /usr/sbin/ntpclient -c ${count:-1} -s -h $hostname -p ${port:-123} 2>&- >&- && DONE=1
33 }
34 }
35 ;;
36 esac
37 }
38 case "${ACTION:-ifup}" in
39 ifup)
40 config_load ntpclient&
41 ;;
42 ifdown)
43 route -n 2>&- | grep '^0.0.0.0' >&- || killall ntpclient 2>&- >&-
44 ;;
45 esac