Add ntpclient config files by Carlos Sobrinho, thanks ! (#1052)
git-svn-id: svn://svn.openwrt.org/openwrt/packages@6116 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
parent
9a003aa17a
commit
dc76950743
@ -37,6 +37,8 @@ endef
|
|||||||
define Package/ntpclient/install
|
define Package/ntpclient/install
|
||||||
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
|
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
|
||||||
$(INSTALL_BIN) ./files/ntpclient.init $(1)/etc/hotplug.d/iface/10-ntpclient
|
$(INSTALL_BIN) ./files/ntpclient.init $(1)/etc/hotplug.d/iface/10-ntpclient
|
||||||
|
$(INSTALL_DIR) $(1)/etc/config
|
||||||
|
$(INSTALL_DATA) ./files/ntpclient.config $(1)/etc/config/ntp_client
|
||||||
$(INSTALL_DIR) $(1)/usr/sbin
|
$(INSTALL_DIR) $(1)/usr/sbin
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ntpclient $(1)/usr/sbin/
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/ntpclient $(1)/usr/sbin/
|
||||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/adjtimex $(1)/usr/sbin/
|
$(INSTALL_BIN) $(PKG_BUILD_DIR)/adjtimex $(1)/usr/sbin/
|
||||||
|
9
net/ntpclient/files/ntpclient.config
Normal file
9
net/ntpclient/files/ntpclient.config
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
config ntp_client
|
||||||
|
option hostname 'pool.ntp.org'
|
||||||
|
option port '123'
|
||||||
|
option count '1'
|
||||||
|
|
||||||
|
config ntp_client
|
||||||
|
option hostname 'ntp.ubuntu.com'
|
||||||
|
option port '123'
|
||||||
|
option count '1'
|
@ -1,13 +1,32 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Copyright (C) 2006 OpenWrt.org
|
# Copyright (C) 2006 OpenWrt.org
|
||||||
|
|
||||||
ntp_server=$(nvram get ntp_server)
|
. /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
|
||||||
|
config_get count $cfg count
|
||||||
|
|
||||||
|
ps x | grep 'bin/[n]tpclient' >&- || {
|
||||||
|
route -n 2>&- | grep '^0.0.0.0' >&- && {
|
||||||
|
/usr/sbin/ntpclient -c ${count:-1} -s -h $hostname -p ${port:-123} 2>&- >&-
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
case "${ACTION:-ifup}" in
|
case "${ACTION:-ifup}" in
|
||||||
ifup)
|
ifup)
|
||||||
ps x | grep 'bin/[n]tpclient' >&- || {
|
config_load ntp_client&
|
||||||
route -n 2>&- | grep '^0.0.0.0' >&- && /usr/sbin/ntpclient -c 1 -s -h ${ntp_server:-pool.ntp.org} &
|
;;
|
||||||
}
|
|
||||||
;;
|
|
||||||
ifdown)
|
ifdown)
|
||||||
route -n 2>&- | grep '^0.0.0.0' >&- || killall ntpclient 2>&- >&- ;;
|
route -n 2>&- | grep '^0.0.0.0' >&- || killall ntpclient 2>&- >&-
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
Loading…
x
Reference in New Issue
Block a user