I spent some time on how to keep backward compatibility for current configurations.

The simplest solution would be to provide 2 systemd unit files:
1. An updated dnsmasq.service file for the main/default/standard "instance", that reflects the fix for checking the configuration (see attached file). 2. The new [email protected] file from the previous post for additional instances.

This way nothing would change for people running just a single dnsmasq instance. No need to rename or sym-link /etc/default/dnsmasq to dnsmasq.main (or similar). Still people could easily create extra instances with the new [email protected] file and a corresponding /etc/default/dnsmasq.<instance> file.


[Unit]
Description=dnsmasq - A lightweight DHCP and caching DNS server
Requires=network.target
Wants=nss-lookup.target
Before=nss-lookup.target
After=network.target

[Service]
Type=forking
PIDFile=/run/dnsmasq/dnsmasq.pid

# Test the config file and refuse starting if it is not valid.
ExecStartPre=/etc/init.d/dnsmasq checkconfig

# 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.
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 like
# 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

[Install]
WantedBy=multi-user.target

Reply via email to