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
|
|
|
|
|
|
|
|
config_cb() {
|
|
|
|
local cfg="$CONFIG_SECTION"
|
|
|
|
local cfgtype
|
|
|
|
config_get cfgtype "$cfg" TYPE
|
|
|
|
|
|
|
|
case "$cfgtype" in
|
|
|
|
ntp_client)
|
|
|
|
config_get hostname $cfg hostname
|
|
|
|
config_get port $cfg port
|
|
|
|
|
|
|
|
ps x | grep 'bin/[n]tpclient' >&- || {
|
|
|
|
route -n 2>&- | grep '^0.0.0.0' >&- && {
|
2007-05-06 15:46:47 +00:00
|
|
|
/usr/sbin/ntpclient -h $hostname -p ${port:-123} 2>&- >&-
|
2007-01-17 19:31:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
2006-08-06 12:40:15 +00:00
|
|
|
case "${ACTION:-ifup}" in
|
|
|
|
ifup)
|
2007-01-17 19:31:22 +00:00
|
|
|
config_load ntp_client&
|
|
|
|
;;
|
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
|