On 20 May 2016 at 02:03, Terry Burton <t...@terryburton.co.uk> wrote: <...snip...> > A general problem that I've noticed which might cause us to modify the > isc-dhcp-server.target approach is that the following commands will > not have the expected effect: > > service isc-dhcp-server {start,stop,restart} > systemctl {start,stop,restart} isc-dhcp-server > > (1) It doesn't appear as though you can invoke .target unit files > using /usr/sbin/service. This'll drive some purists nuts! > (2) Additionally, these commands as-is will actually invoke LSB > compatibility and trigger the sys-v init script rather than the native > isc-dhcp-server.target unit file. > (3) The packaging would need to do something ensure that the > isc-dhcp-server init script (via LSB) and isc-dhcp-server.target unit > are not both started at boot. > > This could spoil an otherwise neat approach. Any suggestions welcome...
So it does not appear that using a target unit to aggregate a group of service files into a single unit of service management is actually aligned to the systemd developers' intentions. Rather target unit are more focussed on machine states and boot processes akin to changing runlevel in sys-v. Shame... The upshot is that patches to /usr/sbin/service (in the sysvinit-utils package) to give the same treatment to .target files as for .service files when overriding an LSB script are unlikely to be accepted which scuppers the original approach by Marc. So please consider for inclusion this simplified approach [1] (also attached). * We have distinct service files for V4 and V6 instances, isc-dhcp-server.service and isc-dhcp-server-v6.service. * They are both enabled and started by default... * ... however they have a precondition on the relevant dhcpd{,6}.conf file existing. * They support INTERFACESv4 and INTERFACESv6 specified in /etc/default/isc-dhcp-server. * As with sys-v, we provide a deprecation warning if INTERFACES is specified, but it is accepted for now. * They support the OPTIONS parameter in /etc/default/isc-dhcp-server (note that support for this is currently lacking in the sys-v script.) * The DHCPDv{4,6}_PID options are not relevant to systemd and so are ignored. * The DHCPDv{4,6}_CONF options are removed because ConditionPathExists requires that these locations be hard-coded. If the user requires these to be different then they can instead override the .service file (overlay in /etc/systemd/system, etc.) as is more usual with systemd. I hope this is acceptable. [1] https://github.com/terryburton/isc-dhcp-debian/commit/f2e4a1cd3c13ee2e77ee855267b24e30a597b562.diff All the best, Terry
diff --git a/debian/control b/debian/control index f873489..9beb3ef 100644 --- a/debian/control +++ b/debian/control @@ -10,6 +10,7 @@ Build-Depends: dpkg-dev (>= 1.13.2), debhelper (>= 9.20151220), dh-autoreconf, + dh-systemd (>= 1.5), groff, pkg-config, po-debconf, diff --git a/debian/isc-dhcp-server.isc-dhcp-server-v6.service b/debian/isc-dhcp-server.isc-dhcp-server-v6.service new file mode 100644 index 0000000..bb4e35c --- /dev/null +++ b/debian/isc-dhcp-server.isc-dhcp-server-v6.service @@ -0,0 +1,10 @@ +[Unit] +Description=ISC DHCP Server for IPv6 (dhcpd6.conf) +After=network.target +ConditionPathExists=/etc/dhcp/dhcpd6.conf + +[Service] +EnvironmentFile=-/etc/default/isc-dhcp-server +ExecStartPre=/usr/bin/touch /var/lib/dhcp/dhcpd6.leases +ExecStartPre=/usr/sbin/dhcpd -f -t -6 -q $OPTIONS -cf /etc/dhcp/dhcpd6.conf +ExecStart=/usr/sbin/dhcpd -f -6 -q $OPTIONS -cf /etc/dhcp/dhcpd6.conf $INTERFACESv6 diff --git a/debian/isc-dhcp-server.service b/debian/isc-dhcp-server.service new file mode 100644 index 0000000..072e6c9 --- /dev/null +++ b/debian/isc-dhcp-server.service @@ -0,0 +1,11 @@ +[Unit] +Description=ISC DHCP Server for IPv4 (dhcpd.conf) +After=network.target +ConditionPathExists=/etc/dhcp/dhcpd.conf + +[Service] +EnvironmentFile=-/etc/default/isc-dhcp-server +ExecStartPre=/bin/sh -c '[ -n "$INTERFACES" -a -z "$INTERFACESv4"] && echo "DHCPv4 interfaces are no longer set by the INTERFACES variable in /etc/default/isc-dhcp-server. Please use INTERFACESv4 instead. Migrating automatically for now, but this will go away in the future." >&2 || true' +ExecStartPre=/usr/bin/touch /var/lib/dhcp/dhcpd.leases +ExecStartPre=/usr/sbin/dhcpd -f -t -4 -q $OPTIONS -cf /etc/dhcp/dhcpd.conf +ExecStart=/usr/sbin/dhcpd -f -4 -q $OPTIONS -cf /etc/dhcp/dhcpd.conf $INTERFACESv4 $INTERFACES diff --git a/debian/rules b/debian/rules index b8358fc..627d98b 100755 --- a/debian/rules +++ b/debian/rules @@ -37,7 +37,7 @@ CONFFLAGS+=--enable-use-sockets endif %: - dh $@ --parallel --with autoreconf + dh $@ --parallel --with autoreconf,systemd override_dh_auto_configure: @@ -83,6 +83,7 @@ override_dh_install: override_dh_installinit: dh_installinit -Nisc-dhcp-server dh_installinit -pisc-dhcp-server --error-handler=true + dh_installinit -pisc-dhcp-server --error-handler=true --name=isc-dhcp-server-v6 override_dh_strip: # this can be removed once stretch is released