#!/bin/sh /etc/rc.common
|
|
# Copyright (C) 2006 OpenWrt.org
|
|
|
|
START=60
|
|
|
|
start() {
|
|
[ ! -f /var/run/chronyd.pid ] && (
|
|
/usr/sbin/chronyd -f /etc/chrony/chrony.conf
|
|
|
|
local NTP_SERVERS
|
|
local NTP_SERVER
|
|
local CLIENT_NETWORKS
|
|
local NETNAME
|
|
config_load ntpd
|
|
config_get NTP_SERVERS $CONFIG_SECTION TimeServers
|
|
config_get CLIENT_NETWORKS $CONFIG_SECTION ClientAccessFrom
|
|
|
|
. /lib/functions/network.sh
|
|
|
|
# Define servers with the iburst option to speed up the initial
|
|
# synchronization and allow clients to access the server
|
|
(
|
|
for NTP_SERVER in $NTP_SERVERS; do
|
|
echo add server $NTP_SERVER iburst
|
|
done
|
|
|
|
for NETNAME in $CLIENT_NETWORKS; do
|
|
local subnet
|
|
if network_get_subnet subnet "$NETNAME"; then
|
|
echo allow $subnet
|
|
fi
|
|
done
|
|
) | chronyc -a > /dev/null 2>&1
|
|
)
|
|
}
|
|
|
|
stop() {
|
|
[ -r /var/run/chronyd.pid ] && PID=$(cat /var/run/chronyd.pid)
|
|
[ -n "$PID" ] && kill $PID
|
|
}
|
|
|
|
restart() {
|
|
stop
|
|
while [ -r /var/run/chronyd.pid ] ; do sleep 1; done
|
|
start
|
|
}
|