diff options
Diffstat (limited to 'meta-networking/recipes-support/dnsmasq/files')
4 files changed, 94 insertions, 16 deletions
diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq-noresolvconf.service b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-noresolvconf.service new file mode 100644 index 0000000000..cde2244c85 --- /dev/null +++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-noresolvconf.service @@ -0,0 +1,15 @@ +[Unit] +Description=DNS forwarder and DHCP server +After=network.target + +[Service] +Type=forking +PIDFile=/run/dnsmasq.pid +ExecStartPre=/usr/bin/dnsmasq --test +ExecStart=/usr/bin/dnsmasq -x /run/dnsmasq.pid +ExecStop=/bin/kill $MAINPID +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target + diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper new file mode 100644 index 0000000000..db54d467e6 --- /dev/null +++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf-helper @@ -0,0 +1,62 @@ +#!/bin/bash +# +# Borrowing heavily from the dnsmasq initscript's version of support for +# resolvconf, intended for use in systemd-only configurations. +# +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DAEMON=/usr/sbin/dnsmasq +NAME=dnsmasq + +# Most configuration options in /etc/default/dnsmasq are deprecated +# but still honoured. +if [ -r /etc/default/$NAME ]; then + . /etc/default/$NAME +fi + +start_resolvconf() +{ + # If interface "lo" is explicitly disabled in /etc/default/dnsmasq + # Then dnsmasq won't be providing local DNS, so don't add it to + # the resolvconf server set. + for interface in $DNSMASQ_EXCEPT + do + [ $interface = lo ] && return + done + + if [ -x /sbin/resolvconf ] ; then + echo "nameserver 127.0.0.1" | + /sbin/resolvconf -a lo.$NAME + fi + return 0 +} + +stop_resolvconf() +{ + if [ -x /sbin/resolvconf ] ; then + /sbin/resolvconf -d lo.$NAME + fi + return 0 +} + +case "$1" in + start) + start_resolvconf + exit 0 + ;; + stop) + stop_resolvconf + exit 0 + ;; + restart) + stop_resolvconf + start_resolvconf + exit 0 + ;; + *) + echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2 + exit 3 + ;; +esac + +exit 0 + diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf.service b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf.service new file mode 100644 index 0000000000..68b175c1fb --- /dev/null +++ b/meta-networking/recipes-support/dnsmasq/files/dnsmasq-resolvconf.service @@ -0,0 +1,17 @@ +[Unit] +Description=DNS forwarder and DHCP server +After=network.target + +[Service] +Type=forking +PIDFile=/run/dnsmasq.pid +ExecStartPre=/usr/bin/dnsmasq --test +ExecStart=/usr/bin/dnsmasq -x /run/dnsmasq.pid +ExecStartPost=/usr/bin/dnsmasq-resolvconf-helper start +ExecStopPre=/usr/bin/dnsmasq-resolvconf-helper stop +ExecStop=/bin/kill $MAINPID +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target + diff --git a/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service b/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service deleted file mode 100644 index c3637e142b..0000000000 --- a/meta-networking/recipes-support/dnsmasq/files/dnsmasq.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=DNS forwarder and DHCP server -After=network.target - -[Service] -Type=forking -PIDFile=/run/dnsmasq.pid -ExecStartPre=/usr/sbin/dnsmasq --test -ExecStart=/etc/init.d/dnsmasq systemd-exec -ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf -ExecStopPre=/etc/init.d/dnsmasq systemd-stop-resolvconf -ExecReload=/bin/kill -HUP $MAINPID - -[Install] -WantedBy=multi-user.target - |