[pkg-ntp-maintainers] [PATCH 2/2] debian/ntp.dhcp, ntp-systemd-netif.service|.path: integrate picking up networkd discovered NTP servers.

Dimitri John Ledkov xnox at ubuntu.com
Tue Oct 3 12:27:32 UTC 2017


networkd has it's own implementation of DHCP client which does not by
default execute isc-dhcp client hooks. However the networkd DHCP
leases are serialised in a runtime directory and it is supported to
establish inotify watches on them. Implement strategy similar to
systemd-timesyncd and take networkd DHCP leases into account in the
dhcp hook. Also add a .path unit to trigger dhcp hook, whenver
networkd leases are updated. This integration enables one to use ntp
for timesyncing on systems that use networkd for networking
configuration, instead of ifupdown + isc-dhclient.
---
 debian/changelog                 | 2 ++
 debian/ntp-systemd-netif.path    | 8 ++++++++
 debian/ntp-systemd-netif.service | 4 ++++
 debian/rules                     | 3 +++
 4 files changed, 17 insertions(+)
 create mode 100644 debian/ntp-systemd-netif.path
 create mode 100644 debian/ntp-systemd-netif.service

diff --git a/debian/changelog b/debian/changelog
index a60266f..3da9f98 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -3,6 +3,8 @@ ntp (1:4.2.8p10+dfsg-6) UNRELEASED; urgency=medium
   * debian/ntp.service: remove conflicts with systemd-timesyncd, as
     timesyncd already neutralises itself if ntp is installed. ntp should
     be preferred as it is a more feature/function complete implementation.
+  * debian/ntp.dhcp,ntp-systemd-netif.service|.path: integrate picking up
+    networkd discovered NTP servers.
 
  -- Dimitri John Ledkov <xnox at ubuntu.com>  Tue, 03 Oct 2017 13:16:10 +0100
 
diff --git a/debian/ntp-systemd-netif.path b/debian/ntp-systemd-netif.path
new file mode 100644
index 0000000..2a24788
--- /dev/null
+++ b/debian/ntp-systemd-netif.path
@@ -0,0 +1,8 @@
+[Unit]
+DefaultDependencies=no
+
+[Path]
+PathChanged=/run/systemd/netif/leases
+
+[Install]
+WantedBy=network-pre.target
diff --git a/debian/ntp-systemd-netif.service b/debian/ntp-systemd-netif.service
new file mode 100644
index 0000000..27610f9
--- /dev/null
+++ b/debian/ntp-systemd-netif.service
@@ -0,0 +1,4 @@
+[Service]
+Environment=reason=BOUND
+ExecStart=/bin/sh -c '. /etc/dhcp/dhclient-exit-hooks.d/ntp'
+
diff --git a/debian/rules b/debian/rules
index 8eb7dd9..42f189e 100755
--- a/debian/rules
+++ b/debian/rules
@@ -36,6 +36,8 @@ override_dh_install:
 	install -D -m 0755 debian/ntp.networkmanager debian/ntp/etc/NetworkManager/dispatcher.d/ntp
 	install -D -m 0644 debian/ntpdate.dhcp debian/ntpdate/etc/dhcp/dhclient-exit-hooks.d/ntpdate
 	install -D -m 0755 debian/ntpdate-debian debian/ntpdate/usr/sbin/ntpdate-debian
+	install -D -m 0644 debian/ntp-systemd-netif.path debian/ntp/lib/systemd/system/ntp-systemd-netif.path
+	install -D -m 0644 debian/ntp-systemd-netif.service debian/ntp/lib/systemd/system/ntp-systemd-netif.service
 
 	install -D -m 0644 debian/ntp.conf debian/ntp/etc/ntp.conf
 
@@ -56,6 +58,7 @@ override_dh_install:
 	rm -f debian/ntp-doc/usr/share/doc/ntp-doc/html/hints/solaris*
 
 override_dh_installinit:
+	dh_systemd_start -pntp ntp-systemd-netif.path
 	dh_installinit -pntp --error-handler=installinit_error --no-restart-after-upgrade
 	dh_installinit -pntpdate --no-restart-after-upgrade
 	dh_apparmor --profile-name=usr.sbin.ntpd -pntp
-- 
2.7.4




More information about the pkg-ntp-maintainers mailing list