2 DAEMON=/usr/bin/dnsmasq
4 DESC="DNS forwarder and DHCP server"
5 ARGS="-7 /etc/dnsmasq.d"
7 test -f $DAEMON || exit 0
11 if [ -r /etc/default/$NAME ]
16 DNSMASQ_CONF="/etc/dnsmasq.conf"
17 test "/etc/dnsmasq.d/*" != '/etc/dnsmasq.d/*' && DNSMASQ_CONF="${DNSMASQ_CONF} /etc/dnsmasq.d/*"
19 test -z "${PIDFILE}" && PIFILE="/run/dnsmasq.pid"
21 if [ -z "$IGNORE_RESOLVCONF" ]
23 egrep -h -q '^no-resolv' ${DNSMASQ_CONF} && IGNORE_RESOLVCONF="yes"
27 # If the resolvconf package is installed then use the resolv conf file
28 # that it provides as the default. Otherwise use /etc/resolv.conf as
31 # If IGNORE_RESOLVCONF is set in /etc/default/dnsmasq or an explicit
32 # filename is set there then this inhibits the use of the resolvconf-provided
35 # Note that if the resolvconf package is installed it is not possible to
36 # override it just by configuration in /etc/dnsmasq.conf, it is necessary
37 # to set IGNORE_RESOLVCONF=yes in /etc/default/dnsmasq.
39 test -z "$RESOLV_CONF" -a "$IGNORE_RESOLVCONF" != "yes" -a -x /sbin/resolvconf && \
40 RESOLV_CONF=/run/dnsmasq/resolv.conf
44 if [ "$IGNORE_RESOLVCONF" != "yes" -a -x /sbin/resolvconf ]
46 echo "nameserver 127.0.0.1" | /sbin/resolvconf -a lo.$NAME
53 if [ "$IGNORE_RESOLVCONF" != "yes" -a -x /sbin/resolvconf ]
55 /sbin/resolvconf -d lo.$NAME
62 echo -n "starting $DESC: $NAME... "
63 test -d /var/lib/misc/ || mkdir /var/lib/misc/
64 start-stop-daemon -S -x $DAEMON -- $ARGS \
65 ${RESOLV_CONF:+ -r $RESOLV_CONF} \
66 ${PIDFILE:+ -x $PIDFILE}
67 test $? -eq 0 && start_resolvconf
71 echo -n "stopping $DESC: $NAME... "
73 start-stop-daemon -K -x $DAEMON
78 start-stop-daemon -q -K -t -x $DAEMON
80 if [ "$RET" = "0" ]; then
82 echo "($PID) is running"
89 echo "restarting $DESC: $NAME... "
95 echo -n "reloading $DESC: $NAME... "
96 killall -HUP $(basename ${DAEMON})
99 systemd-start-resolvconf)
102 systemd-stop-resolvconf)
106 test -d /var/lib/misc/ || mkdir /var/lib/misc/
107 exec $DAEMON --keep-in-foreground $ARGS \
108 ${RESOLV_CONF:+ -r $RESOLV_CONF} \
109 ${PIDFILE:+ -x $PIDFILE}
112 echo "Usage: $0 {start|stop|status|restart|reload}"