Eliminate EnvironmentFile from systemd unit descriptions. /etc/ntp.conf
can't be sourced to set environment variables like NTPD_ARG. Following the
rationale at http://0pointer.de/blog/projects/on-etc-sysinit.html it isn't
needed anyway; if you don't buy that, it should be:
EnvironmentFile=-/etc/default/ntpd
Add one-shot ntpdate service which synchronizes local clock prior to
starting ntpd (which aborts if the local time is more than 1000 seconds off
of the server). "systemctl enable ntpdate.service" not done by default
because this would be a behavior change.
Correct comment describing how to replace ntpdate (ntpdc doesn't take those
arguments).
Add comment to ntp.conf pointing out need to remove local hardware clock as
a reference when simulating ntpdate.
(From meta-openembedded rev:
42d6f4f36696faaf0e526b14bcc6daff51ab943b)
Signed-off-by: Peter A. Bigot <bigotp@acm.org>
Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
# as required, or change this.
server pool.ntp.org
# Using local hardware clock as fallback
+# Disable this when using ntpd -q -g -x as ntpdate or it will sync to itself
server 127.127.1.0
fudge 127.127.1.0 stratum 14
# Defining a default security setting
[Service]
Type=forking
PIDFile=/run/ntpd.pid
-EnvironmentFile=/etc/ntp.conf
-ExecStart=/usr/bin/ntpd $NTPD_ARGS -p /run/ntpd.pid
+ExecStart=/usr/bin/ntpd -p /run/ntpd.pid
[Install]
WantedBy=multi-user.target
--- /dev/null
+[Unit]
+Description=Network Time Service (one-shot ntpdate mode)
+Before=ntpd.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/ntpd -q -g -x
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
CFLAGS_append = " -DPTYS_ARE_GETPT -DPTYS_ARE_SEARCHED"
PACKAGES += "ntpdate ${PN}-bin ${PN}-tickadj ${PN}-utils"
-# NOTE: you don't need ntpdate, use "ntpdc -q -g -x"
+# NOTE: you don't need ntpdate, use "ntpd -q -g -x"
+# or the ntpdate systemd service
# This should use rc.update
FILES_ntpdate = "${bindir}/ntpdate ${sysconfdir}/init.d/ntpdate"
require ntp.inc
-PR = "r3"
+PR = "r4"
inherit systemd
file://ntpd \
file://ntp.conf \
file://ntpdate \
+ file://ntpdate.service \
file://ntpd.service \
"
install -m 755 ${WORKDIR}/ntpdate ${D}/${sysconfdir}/network/if-up.d
install -d ${D}${base_libdir}/systemd/system
+ install -m 0644 ${WORKDIR}/ntpdate.service ${D}${base_libdir}/systemd/system/
install -m 0644 ${WORKDIR}/ntpd.service ${D}${base_libdir}/systemd/system/
}