Merge "NTP fail to sync if time sync is not performed"
This commit is contained in:
commit
5b23452f69
@ -14,11 +14,19 @@ filegen clockstats file clockstats type day enable
|
||||
restrict -4 default kod notrap nomodify nopeer noquery
|
||||
restrict -6 default kod notrap nomodify nopeer noquery
|
||||
|
||||
# Local users get more
|
||||
# Local users may interrogate the ntp server more closely.
|
||||
restrict 127.0.0.1
|
||||
restrict ::1
|
||||
|
||||
# Remote NTP server(s) to synchronize with.
|
||||
{{#ntp.servers}}
|
||||
{{#server}}
|
||||
server {{server}}
|
||||
{{#fudge}}fudge {{server}} {{fudge}}{{/fudge}}
|
||||
{{/server}}
|
||||
{{/ntp.servers}}
|
||||
|
||||
# Specify the internal hardware clock as a reference clock.
|
||||
# Set a high stratum so this is only used if all external clocks fail.
|
||||
# This will mitigate skew until external clocks return to service.
|
||||
server 127.127.1.0 # local clock address
|
||||
fudge 127.127.1.0 stratum 10
|
||||
|
22
elements/ntp/os-refresh-config/configure.d/50-ntp
Executable file
22
elements/ntp/os-refresh-config/configure.d/50-ntp
Executable file
@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
set -eu
|
||||
set -o pipefail
|
||||
|
||||
# NTP server to sync with.
|
||||
NTP_SERVER="$(os-apply-config --key 'ntp.servers.0.server' --type raw --key-default '')"
|
||||
SERVICE_NAME="$(svc-map ntpd)"
|
||||
|
||||
if [ -n "${NTP_SERVER}" ]; then
|
||||
ntpdate -q "${NTP_SERVER}" ||
|
||||
{ echo "ERROR: ntpdate cannot connect to: ${NTP_SERVER}"; exit 1; }
|
||||
|
||||
# Check ntpd is running, if it is stop the service.
|
||||
service "${SERVICE_NAME}" status && service "${SERVICE_NAME}" stop
|
||||
|
||||
# Set the system clock to the value of the NTP clock.
|
||||
# Note: This will not sanity check the ntp server like ntpd.
|
||||
ntpdate -b "${NTP_SERVER}"
|
||||
hwclock --systohc # Re-align the H/W clock. (incase of power loss)
|
||||
|
||||
service "${SERVICE_NAME}" start
|
||||
fi
|
@ -1,2 +0,0 @@
|
||||
#!/bin/sh
|
||||
service ntp restart || service ntpd restart
|
3
elements/ntp/svc-map
Normal file
3
elements/ntp/svc-map
Normal file
@ -0,0 +1,3 @@
|
||||
ntpd:
|
||||
default: ntp
|
||||
redhat: ntpd
|
Loading…
Reference in New Issue
Block a user