From 456f883a106e90005da5baf4d2adbd6c6af032a1 Mon Sep 17 00:00:00 2001 From: Florian Fainelli Date: Wed, 17 Jan 2007 19:31:22 +0000 Subject: [PATCH] Add ntpclient config files by Carlos Sobrinho, thanks ! (#1052) SVN-Revision: 6116 --- net/ntpclient/Makefile | 2 ++ net/ntpclient/files/ntpclient.config | 9 ++++++++ net/ntpclient/files/ntpclient.init | 31 ++++++++++++++++++++++------ 3 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 net/ntpclient/files/ntpclient.config diff --git a/net/ntpclient/Makefile b/net/ntpclient/Makefile index c1bae5569..502def60e 100644 --- a/net/ntpclient/Makefile +++ b/net/ntpclient/Makefile @@ -37,6 +37,8 @@ endef define Package/ntpclient/install $(INSTALL_DIR) $(1)/etc/hotplug.d/iface $(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_BIN) $(PKG_BUILD_DIR)/ntpclient $(1)/usr/sbin/ $(INSTALL_BIN) $(PKG_BUILD_DIR)/adjtimex $(1)/usr/sbin/ diff --git a/net/ntpclient/files/ntpclient.config b/net/ntpclient/files/ntpclient.config new file mode 100644 index 000000000..5be82ca16 --- /dev/null +++ b/net/ntpclient/files/ntpclient.config @@ -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' diff --git a/net/ntpclient/files/ntpclient.init b/net/ntpclient/files/ntpclient.init index f508c313c..38cba5e0e 100644 --- a/net/ntpclient/files/ntpclient.init +++ b/net/ntpclient/files/ntpclient.init @@ -1,13 +1,32 @@ #!/bin/sh # 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 ifup) - ps x | grep 'bin/[n]tpclient' >&- || { - route -n 2>&- | grep '^0.0.0.0' >&- && /usr/sbin/ntpclient -c 1 -s -h ${ntp_server:-pool.ntp.org} & - } - ;; + config_load ntp_client& + ;; ifdown) - route -n 2>&- | grep '^0.0.0.0' >&- || killall ntpclient 2>&- >&- ;; + route -n 2>&- | grep '^0.0.0.0' >&- || killall ntpclient 2>&- >&- + ;; esac -- 2.30.2