Debian systemd startup fixes for resolvconf integration.
diff --git a/debian/changelog b/debian/changelog
index 5d14655..e6d4336 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,14 @@
* New upstream.
- -- Simon Kelley <simon@thekelleys.org.uk> Thu, 7 Jun 2012 15:31:35 +0000
+ -- Simon Kelley <simon@thekelleys.org.uk> Mon, 11 Jun 2012 21:55:35 +0000
+
+dnsmasq (2.62-3) unstable; urgency=low
+
+ * Do resolvconf and /etc/default startup logic when
+ starting with systemd. (closes: #675854)
+
+ -- Simon Kelley <simon@thekelleys.org.uk> Mon, 11 Jun 2012 21:50:11 +0000
dnsmasq (2.62-2) unstable; urgency=low
diff --git a/debian/init b/debian/init
index 0ca08d7..df4dc08 100644
--- a/debian/init
+++ b/debian/init
@@ -259,6 +259,27 @@
dump-stats)
kill -s USR1 `cat /var/run/dnsmasq/$NAME.pid`
;;
+ systemd-start-resolvconf)
+ start_resolvconf
+ ;;
+ systemd-stop-resolvconf)
+ stop_resolvconf
+ ;;
+ systemd-exec)
+# --pid-file without argument disables writing a PIDfile, we don't need one with sytemd.
+# Enable DBus by default because we use DBus activation with systemd.
+ exec $DAEMON --keep-in-foreground --pid-file --enable-dbus \
+ ${MAILHOSTNAME:+ -m $MAILHOSTNAME} \
+ ${MAILTARGET:+ -t $MAILTARGET} \
+ ${DNSMASQ_USER:+ -u $DNSMASQ_USER} \
+ ${DNSMASQ_INTERFACES:+ $DNSMASQ_INTERFACES} \
+ ${DHCP_LEASE:+ -l $DHCP_LEASE} \
+ ${DOMAIN_SUFFIX:+ -s $DOMAIN_SUFFIX} \
+ ${RESOLV_CONF:+ -r $RESOLV_CONF} \
+ ${CACHESIZE:+ -c $CACHESIZE} \
+ ${CONFIG_DIR:+ -7 $CONFIG_DIR} \
+ ${DNSMASQ_OPTS:+ $DNSMASQ_OPTS}
+ ;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload|dump-stats|status}" >&2
exit 3
diff --git a/debian/systemd.service b/debian/systemd.service
index 036287d..d75ab62 100644
--- a/debian/systemd.service
+++ b/debian/systemd.service
@@ -8,22 +8,24 @@
# Test the config file and refuse starting if it is not valid.
ExecStartPre=/usr/sbin/dnsmasq --test
-# Enable DBus by default because we use DBus activation.
+# We run dnsmasq via the /etc/init.d/dnsmasq script which acts as a
+# wrapper picking up extra configuration files and then execs dnsmasq
+# itself, when called with the "systemd-exec" function.
#
-# Drop privileges and become the 'dnsmasq' user. It is recommended by dnsmasq
-# upstream to run dnsmasq as an isolated user that does not run any other
-# processes, owns no files and has no shell. The default 'nobody' user has a
-# shell and might be used for other processes.
+# It also adds the command-line flags
+# --keep-in-foreground --pid-file --enable-dbus
+# to disable writing a pid-file (not needed with systemd) and
+# enable DBus by default because we use DBus activation.
#
-# Debian-specific: add /etc/dnsmasq.d to config search path (with the exception
-# of .dpkg-*). Packages such as libvirt leave config files there.
-#
-# --pid-file without argument disables writing a PIDfile, we don't need one.
-ExecStart=/usr/sbin/dnsmasq -k \
- --enable-dbus \
- --user=dnsmasq \
- -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new \
- --pid-file
+ExecStart=/etc/init.d/dnsmasq systemd-exec
+
+# The systemd-*-resolvconf functions configure (and deconfigure)
+# resolvconf to work with the dnsmasq DNS server. They're called liek
+# this to get correct error handling (ie don't start-resolvconf if the
+# dnsmasq daemon fails to start.
+ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf
+ExecStop=/etc/init.d/dnsmasq systemd-stop-resolvconf
+
ExecReload=/bin/kill -HUP $MAINPID