5e7462deb8
git-svn-id: svn://svn.openwrt.org/openwrt/packages@6944 3c298f89-4303-0410-b956-a3cf2f4a3e73
32 lines
587 B
Bash
32 lines
587 B
Bash
#!/bin/sh
|
|
# Copyright (C) 2006 OpenWrt.org
|
|
|
|
. /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' >&- && {
|
|
/usr/sbin/ntpclient -s -h $hostname -p ${port:-123} 2>&- >&-
|
|
}
|
|
}
|
|
;;
|
|
esac
|
|
}
|
|
case "${ACTION:-ifup}" in
|
|
ifup)
|
|
config_load ntp_client&
|
|
;;
|
|
ifdown)
|
|
route -n 2>&- | grep '^0.0.0.0' >&- || killall ntpclient 2>&- >&-
|
|
;;
|
|
esac
|