I've also hit this problem of the race condition with ntpdate.

If ntpd dies for whatever reason (port in use, somebody stomping about
with kill to prove the point) systemd thinks that this is fine. System
configuration tools like Puppet won't try to start ntpd again as
"systemctl status ntp" returns ok.

The sysv shim just isn't good enough.

I ended up rolling my own local ntp package with a systemd unit file.

Patch against ntp_4.2.6.p5+dfsg-7+deb8u1

Dan
diff -ruN a/debian/control b/debian/control
--- a/debian/control	2015-10-23 18:04:42.000000000 +0100
+++ b/debian/control	2015-11-02 10:46:26.000000000 +0000
@@ -3,7 +3,7 @@
 Priority: optional
 Maintainer: Debian NTP Team <pkg-ntp-maintain...@lists.alioth.debian.org>
 Uploaders: Bdale Garbee <bd...@gag.com>, Peter Eisentraut <pet...@debian.org>, Kurt Roeckx <k...@roeckx.be>
-Build-Depends: dh-autoreconf, debhelper (>= 6), libedit-dev, libcap2-dev [linux-any], libssl-dev (>= 1.0.0e-1), autogen (>= 1:5.11), bison
+Build-Depends: dh-autoreconf, debhelper (>= 6), libedit-dev, libcap2-dev [linux-any], libssl-dev (>= 1.0.0e-1), autogen (>= 1:5.11), bison, dh-systemd
 Build-Conflicts: libavahi-compat-libdnssd-dev, libwww-dev, libwww-ssl-dev
 Standards-Version: 3.9.3
 Homepage: http://support.ntp.org/
diff -ruN a/debian/ntp.service b/debian/ntp.service
--- a/debian/ntp.service	1970-01-01 01:00:00.000000000 +0100
+++ b/debian/ntp.service	2015-11-02 10:46:36.000000000 +0000
@@ -0,0 +1,15 @@
+[Unit]
+Description=Network Time Service
+After=network-online.target syslog.socket
+Before=time-sync.target
+Wants=time-sync.target network-online.target
+Conflicts=systemd-timesyncd.service
+
+[Service]
+Type=forking
+EnvironmentFile=-/etc/default/ntp
+ExecStart=/usr/sbin/ntpd -u ntp:ntp $NTPD_OPTS
+PrivateTmp=true
+
+[Install]
+WantedBy=multi-user.target
diff -ruN a/debian/rules b/debian/rules
--- a/debian/rules	2014-07-16 17:49:08.000000000 +0100
+++ b/debian/rules	2015-11-02 10:47:52.000000000 +0000
@@ -95,8 +95,10 @@
 	dh_installdocs -a
 	dh_installexamples -a
 	dh_installman -a
+	dh_systemd_enable
 	dh_installinit -pntp --update-rcd-params="start 23 2 3 4 5 ." --error-handler=installinit_error
 	dh_installinit -pntpdate
+	dh_systemd_start
 	dh_installcron -a
 	dh_installlogcheck -a
 	dh_installchangelogs -a

Reply via email to