mirror of https://github.com/aredn/aredn.git
Periodically sync time if continuous ntpd is unsynchronized (#1611)
When update-clock is run periodically, if ntpd is running continuously, check whether it is actually in sync, as measured by a reported stratum of less than 16. If it's not in sync, run the full manual clock sync algorithm otherwise used for our periodic-only synchronization. This should help with hosts that expect to synchronize from an NTP server on the internet, for example, when they've temporarily lost the internet connection. Or alternately, if configured to use a mesh-based NTP server that has disappeared from the mesh.
This commit is contained in:
parent
e6943bd0d1
commit
65b09ab8b7
|
@ -41,9 +41,11 @@ exec 2> /dev/null
|
||||||
|
|
||||||
# If real ntp is running, we don't need to do this
|
# If real ntp is running, we don't need to do this
|
||||||
if [ "$(pidof ntpd)" != "" ]; then
|
if [ "$(pidof ntpd)" != "" ]; then
|
||||||
|
if [ -f /var/state/ntp-stratum ] && [ $(cat /var/state/ntp-stratum) -lt 16 ]; then
|
||||||
echo -n "ntp" > /tmp/timesync
|
echo -n "ntp" > /tmp/timesync
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
for candidate in $(uci -q get system.ntp.server)
|
for candidate in $(uci -q get system.ntp.server)
|
||||||
do
|
do
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
STATEFILE="/var/state/ntp-stratum"
|
||||||
|
|
||||||
|
if [[ "${stratum}" != "" ]]; then
|
||||||
|
echo "${stratum}" > "${STATEFILE}"
|
||||||
|
fi
|
Loading…
Reference in New Issue