Package: bind9
Version: 1:9.8.4.dfsg.P1-6+nmu2
Severity: normal
Tags: patch
User: [email protected]
Usertags: systemd-units

Hi,

Attached you can find a patch which adds systemd service files to the
bind9 source package. It covers both bind9 and lwresd.

The systemd service files provide the same functionality as the init
script did, but with a slightly different interface:

 • The OPTIONS variable is implicitly provided by the override
   functionality of systemd: instead of sourcing /etc/default/bind9, the
   system administrator can create
   /etc/systemd/system/bind9.service.d/different-user.conf (starting
   with systemd ≥ 198, for older versions you can use .include) and
   specify the directives she wants to add/overwrite in that file.

 • The RESOLVCONF variable is provided by the additional service file
   bind9-resolvconf.service, which the system administrator can enable
   in case she wants to use the local BIND server as nameserver using
   resolvconf(8).

I also attached a debdiff between the version currently in Debian and a
version built with my patch. Use:

    colordiff --difftype=debdiff < systemd.debdiff

(colordiff's highlighting is not entirely correct, but very helpful.)

For more details on systemd packaging, see
http://wiki.debian.org/Systemd/Packaging
In case of any questions, feel free to drop by in #debian-systemd or
send an email to [email protected]

-- 
Best regards,
Michael

Attachment: systemd.debdiff
Description: Binary data

>From b23b21b895fe6fd7c6a2f83e3be8413b9a57b6f9 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <[email protected]>
Date: Sun, 28 Jul 2013 21:14:24 +0200
Subject: [PATCH] add systemd service files for bind9 and lwresd

---
 debian/bind9-resolvconf.service |   13 +++++++++++++
 debian/bind9.service            |   12 ++++++++++++
 debian/bind9.tmpfile            |    1 +
 debian/control                  |    2 +-
 debian/lwresd.service           |   10 ++++++++++
 debian/lwresd.tmpfile           |    1 +
 debian/rules                    |    5 +++++
 7 files changed, 43 insertions(+), 1 deletion(-)
 create mode 100644 debian/bind9-resolvconf.service
 create mode 100644 debian/bind9.service
 create mode 100644 debian/bind9.tmpfile
 create mode 100644 debian/lwresd.service
 create mode 100644 debian/lwresd.tmpfile

diff --git a/debian/bind9-resolvconf.service b/debian/bind9-resolvconf.service
new file mode 100644
index 0000000..3426c1f
--- /dev/null
+++ b/debian/bind9-resolvconf.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=local BIND via resolvconf
+Documentation=man:named(8) man:resolvconf(8)
+Requires=bind9.service
+After=bind9.service
+ConditionFileIsExecutable=/sbin/resolvconf
+
+[Service]
+ExecStart=/bin/sh -c 'echo nameserver 127.0.0.1 | /sbin/resolvconf -a lo.named'
+ExecStop=/sbin/resolvconf -d lo.named
+
+[Install]
+WantedBy=bind9.service
diff --git a/debian/bind9.service b/debian/bind9.service
new file mode 100644
index 0000000..5cbafa1
--- /dev/null
+++ b/debian/bind9.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=BIND Domain Name Server
+Documentation=man:named(8)
+After=network.target
+
+[Service]
+ExecStart=/usr/sbin/named -f -u bind
+ExecReload=/usr/sbin/rndc reload
+ExecStop=/usr/sbin/rndc stop
+
+[Install]
+WantedBy=multi-user.target
diff --git a/debian/bind9.tmpfile b/debian/bind9.tmpfile
new file mode 100644
index 0000000..36fc91d
--- /dev/null
+++ b/debian/bind9.tmpfile
@@ -0,0 +1 @@
+d /run/named 0775 root bind - -
diff --git a/debian/control b/debian/control
index 550d04d..1d4fad7 100644
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,7 @@ Section: net
 Priority: optional
 Maintainer: LaMont Jones <[email protected]>
 Uploaders: Bdale Garbee <[email protected]>
-Build-Depends: libkrb5-dev, debhelper (>= 5), libssl-dev, libtool, bison, libdb-dev (>>4.6), libldap2-dev, libxml2-dev, libcap2-dev [!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386], hardening-wrapper, libgeoip-dev (>= 1.4.6.dfsg-5), dpkg-dev (>= 1.15.5)
+Build-Depends: libkrb5-dev, debhelper (>= 5), libssl-dev, libtool, bison, libdb-dev (>>4.6), libldap2-dev, libxml2-dev, libcap2-dev [!kfreebsd-i386 !kfreebsd-amd64 !hurd-i386], hardening-wrapper, libgeoip-dev (>= 1.4.6.dfsg-5), dpkg-dev (>= 1.15.5), dh-systemd
 Build-Conflicts: libdb4.2-dev
 Standards-Version: 3.7.3.0
 XS-Vcs-Browser: http://git.debian.org/?p=users/lamont/bind9.git
diff --git a/debian/lwresd.service b/debian/lwresd.service
new file mode 100644
index 0000000..64a34a5
--- /dev/null
+++ b/debian/lwresd.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Lightweight Resolver Daemon
+Documentation=man:lwresd(8)
+After=network.target
+
+[Service]
+ExecStart=/usr/sbin/lwresd -f
+
+[Install]
+WantedBy=multi-user.target
diff --git a/debian/lwresd.tmpfile b/debian/lwresd.tmpfile
new file mode 100644
index 0000000..ffdd79e
--- /dev/null
+++ b/debian/lwresd.tmpfile
@@ -0,0 +1 @@
+d /run/lwresd 0775 root bind - -
diff --git a/debian/rules b/debian/rules
index a87c78e..b1750d5 100755
--- a/debian/rules
+++ b/debian/rules
@@ -145,7 +145,12 @@ binary-arch: build install
 	dh_installdocs -a
 	dh_installexamples -a
 	dh_installmenu -a
+	dh_systemd_enable -pbind9 --no-enable bind9-resolvconf.service
+	dh_systemd_enable -pbind9 bind9.service
+	dh_systemd_enable -plwresd lwresd.service
 	dh_installinit -a --no-start -- defaults 15 85
+	# Ship the extra service file for resolvconf integration manually.
+	cp debian/bind9-resolvconf.service debian/bind9/lib/systemd/system
 	dh_installcron -a
 	dh_installdebconf -pbind9
 	dh_installinfo -a
-- 
1.7.10.4

Reply via email to