mirror of
https://github.com/novatiq/packages.git
synced 2026-04-30 07:28:39 +01:00
chrony: import from oldpackages
Signed-off-by: Miroslav Lichvar <mlichvar0@gmail.com>
This commit is contained in:
committed by
Steven Barth
parent
0f6e674a62
commit
71559ae85f
@@ -0,0 +1,12 @@
|
||||
# This file is included from config file generated from /etc/config/chrony
|
||||
|
||||
# Log clock errors above 0.5 seconds
|
||||
logchange 0.5
|
||||
|
||||
# Don't log client accesses
|
||||
noclientlog
|
||||
|
||||
# Password config for chronyc
|
||||
keyfile /etc/chrony/chrony.keys
|
||||
commandkey 1
|
||||
generatecommandkey
|
||||
@@ -0,0 +1,11 @@
|
||||
config pool
|
||||
option hostname '2.openwrt.pool.ntp.org'
|
||||
option maxpoll '12'
|
||||
option iburst 'yes'
|
||||
|
||||
config allow
|
||||
option interface 'lan'
|
||||
|
||||
config makestep
|
||||
option threshold '1.0'
|
||||
option limit '3'
|
||||
@@ -0,0 +1,6 @@
|
||||
COMMAND=/usr/bin/chronyc
|
||||
|
||||
[ -x $COMMAND ] || exit 0
|
||||
|
||||
[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && $COMMAND -a online
|
||||
[ "$ACTION" = "ifdown" -a "$INTERFACE" = "wan" ] && $COMMAND -a offline
|
||||
@@ -0,0 +1 @@
|
||||
# Keys for NTP authentication and chronyc commands
|
||||
@@ -0,0 +1,69 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
|
||||
START=60
|
||||
USE_PROCD=1
|
||||
PROG=/usr/sbin/chronyd
|
||||
CONFIGFILE=/var/etc/chrony.conf
|
||||
|
||||
handle_source() {
|
||||
local cfg=$1 sourcetype=$2 hostname minpoll maxpoll iburst
|
||||
|
||||
config_get hostname "$cfg" hostname
|
||||
[ -z "$hostname" ] && return
|
||||
config_get minpoll "$cfg" minpoll
|
||||
config_get maxpoll "$cfg" maxpoll
|
||||
config_get_bool iburst "$cfg" iburst 0
|
||||
echo $(
|
||||
echo $sourcetype $hostname
|
||||
[ -n "$minpoll" ] && echo minpoll $minpoll
|
||||
[ -n "$maxpoll" ] && echo maxpoll $maxpoll
|
||||
[ "$iburst" = "1" ] && echo iburst
|
||||
) >> $CONFIGFILE
|
||||
}
|
||||
|
||||
handle_allow() {
|
||||
local cfg=$1 iface wan_iface wan6_iface subnet subnets subnets6
|
||||
|
||||
network_find_wan wan_iface true
|
||||
network_find_wan6 wan6_iface true
|
||||
config_get iface "$cfg" interface
|
||||
|
||||
if [ "$wan_iface" = "$iface" ]; then
|
||||
echo allow >> $CONFIGFILE
|
||||
else
|
||||
network_get_subnets subnets $iface || \
|
||||
network_get_subnets subnets6 $iface || continue
|
||||
for subnet in $subnets $subnets6; do
|
||||
echo allow $subnet >> $CONFIGFILE
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
handle_makestep() {
|
||||
local cfg=$1 threshold limit
|
||||
|
||||
config_get threshold "$cfg" threshold
|
||||
config_get limit "$cfg" limit
|
||||
[ -z "$threshold" -o -z "$limit" ] && return
|
||||
echo makestep $threshold $limit >> $CONFIGFILE
|
||||
}
|
||||
|
||||
start_service() {
|
||||
. /lib/functions/network.sh
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command $PROG -n -f $CONFIGFILE
|
||||
procd_set_param file $CONFIGFILE
|
||||
procd_set_param file /etc/chrony/chrony.conf
|
||||
procd_close_instance
|
||||
|
||||
echo include /etc/chrony/chrony.conf > $CONFIGFILE
|
||||
|
||||
config_load ntpd
|
||||
config_foreach handle_source server server
|
||||
config_foreach handle_source pool pool
|
||||
config_foreach handle_source peer peer
|
||||
config_foreach handle_allow allow
|
||||
config_foreach handle_makestep makestep
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
# Generic NTP configuration
|
||||
# Time servers and network(s) that may access the time service
|
||||
|
||||
config ntpd
|
||||
option TimeServers "0.openwrt.pool.ntp.org 1.openwrt.pool.ntp.org 2.openwrt.pool.ntp.org 3.openwrt.pool.ntp.org"
|
||||
option ClientAccessFrom "lan"
|
||||
@@ -0,0 +1,6 @@
|
||||
COMMAND=/usr/bin/chronyc
|
||||
|
||||
[ -x $COMMAND ] || exit 0
|
||||
|
||||
[ "$ACTION" = "ifup" -a "$INTERFACE" = "wan" ] && $COMMAND -a online
|
||||
[ "$ACTION" = "ifdown" -a "$INTERFACE" = "wan" ] && $COMMAND -a offline
|
||||
@@ -0,0 +1,46 @@
|
||||
#!/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
|
||||
}
|
||||
Reference in New Issue
Block a user