ntpclient: Import from oldpackages, update version, copyright and license info, add pkg maintainer.

Signed-off-by: Ted Hess <thess@kitschensync.net>
This commit is contained in:
Ted Hess
2014-08-13 17:06:00 -04:00
parent ca7ddc5abc
commit c839c2119b
4 changed files with 180 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
config ntpserver
option hostname '0.openwrt.pool.ntp.org'
option port '123'
config ntpserver
option hostname '1.openwrt.pool.ntp.org'
option port '123'
config ntpserver
option hostname '2.openwrt.pool.ntp.org'
option port '123'
config ntpserver
option hostname '3.openwrt.pool.ntp.org'
option port '123'
config ntpdrift
option freq '0'
config ntpclient
option interval 600
#option count 10
#option interface wan
+78
View File
@@ -0,0 +1,78 @@
#!/bin/sh
# Copyright (C) 2006-2014 OpenWrt.org
. /lib/functions.sh
unset SERVER
unset PORT
unset INTERVAL
unset COUNT
unset INTERFACE_GLOBAL
NTPC=`which ntpclient`
check_server() {
local hostname
local port
local interface
[ -n "$SERVER" ] && return
config_get hostname $1 hostname
config_get port $1 port
config_get interface $1 interface
[ -z "$interface" ] && interface=$INTERFACE_GLOBAL
[ -n "$interface" ] && {
# $INTERFACE is passed from hotplug event
[ "$interface" = "$INTERFACE" ] || return
}
[ -z "$hostname" ] && return
$NTPC -c 1 -p ${port:-123} -i 2 -h $hostname > /dev/null && { SERVER=$hostname; PORT=${port:-123}; }
}
set_drift() {
config_get freq $1 freq
[ -n "$freq" ] && adjtimex -f $freq >/dev/null
}
start_ntpclient() {
config_foreach set_drift ntpdrift
config_foreach check_server ntpserver
[ -z "$SERVER" ] && exit 0
logger starting ntpclient
$NTPC ${COUNT:+-c $COUNT} ${INTERVAL:+-i $INTERVAL} -s -l -D -p $PORT -h $SERVER 2> /dev/null
}
stop_ntpclient() {
logger stopping ntpclient
killall ntpclient
}
load_settings() {
local interval
local count
local iface
config_get interval $1 interval
config_get count $1 count
config_get interface $1 interface
[ -n "$count" ] && COUNT=$count
[ -n "$interval" ] && INTERVAL=$interval
[ -n "$interface" ] && INTERFACE_GLOBAL=$interface
}
config_load ntpclient
config_foreach load_settings ntpclient
NTP_RUNNING=`ps | grep $NTPC | grep -v grep`
case "${ACTION:-ifup}" in
ifup)
[ -z "$NTP_RUNNING" ] && start_ntpclient
;;
ifdown)
[ -n "$NTP_RUNNING" ] && stop_ntpclient
;;
esac