2006-08-06 12:40:15 +00:00
|
|
|
#!/bin/sh
|
2006-10-04 20:57:49 +00:00
|
|
|
# Copyright (C) 2006 OpenWrt.org
|
|
|
|
|
2007-01-17 19:31:22 +00:00
|
|
|
. /etc/functions.sh
|
|
|
|
|
2007-06-28 21:04:47 +00:00
|
|
|
DONE=0
|
2007-01-17 19:31:22 +00:00
|
|
|
config_cb() {
|
|
|
|
local cfg="$CONFIG_SECTION"
|
|
|
|
local cfgtype
|
|
|
|
config_get cfgtype "$cfg" TYPE
|
|
|
|
|
|
|
|
case "$cfgtype" in
|
2007-07-30 08:34:04 +00:00
|
|
|
ntpclient)
|
2007-01-17 19:31:22 +00:00
|
|
|
config_get hostname $cfg hostname
|
|
|
|
config_get port $cfg port
|
2008-01-14 10:38:27 +00:00
|
|
|
config_get count $cfg count
|
2007-06-28 21:04:47 +00:00
|
|
|
|
|
|
|
[ "$DONE" = "1" ] && exit 0
|
2007-09-30 21:13:13 +00:00
|
|
|
ps | grep 'bin/[n]tpclient' >&- || {
|
2007-01-17 19:31:22 +00:00
|
|
|
route -n 2>&- | grep '^0.0.0.0' >&- && {
|
2007-06-28 21:04:47 +00:00
|
|
|
/usr/sbin/ntpclient -c ${count:-1} -s -h $hostname -p ${port:-123} 2>&- >&- && DONE=1
|
2007-01-17 19:31:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
2006-08-06 12:40:15 +00:00
|
|
|
case "${ACTION:-ifup}" in
|
|
|
|
ifup)
|
2007-07-30 08:34:04 +00:00
|
|
|
config_load ntpclient&
|
2007-01-17 19:31:22 +00:00
|
|
|
;;
|
2006-08-06 12:40:15 +00:00
|
|
|
ifdown)
|
2007-01-17 19:31:22 +00:00
|
|
|
route -n 2>&- | grep '^0.0.0.0' >&- || killall ntpclient 2>&- >&-
|
|
|
|
;;
|
2006-08-06 12:40:15 +00:00
|
|
|
esac
|