diff options
Diffstat (limited to 'meta-networking/recipes-support/dnsmasq/files/init')
-rw-r--r-- | meta-networking/recipes-support/dnsmasq/files/init | 69 |
1 files changed, 67 insertions, 2 deletions
diff --git a/meta-networking/recipes-support/dnsmasq/files/init b/meta-networking/recipes-support/dnsmasq/files/init index d1aa9e517d..51c95dfedd 100644 --- a/meta-networking/recipes-support/dnsmasq/files/init +++ b/meta-networking/recipes-support/dnsmasq/files/init @@ -8,15 +8,68 @@ test -f $DAEMON || exit 0 set -e +if [ -r /etc/default/$NAME ] +then + . /etc/default/$NAME +fi + +DNSMASQ_CONF="/etc/dnsmasq.conf" +test "/etc/dnsmasq.d/*" != '/etc/dnsmasq.d/*' && DNSMASQ_CONF="${DNSMASQ_CONF} /etc/dnsmasq.d/*" + +test -z "${PIDFILE}" && PIFILE="/run/dnsmasq.pid" + +if [ -z "$IGNORE_RESOLVCONF" ] +then + egrep -h -q '^no-resolv' ${DNSMASQ_CONF} && IGNORE_RESOLVCONF="yes" +fi + +# RESOLV_CONF: +# If the resolvconf package is installed then use the resolv conf file +# that it provides as the default. Otherwise use /etc/resolv.conf as +# the default. +# +# If IGNORE_RESOLVCONF is set in /etc/default/dnsmasq or an explicit +# filename is set there then this inhibits the use of the resolvconf-provided +# information. +# +# Note that if the resolvconf package is installed it is not possible to +# override it just by configuration in /etc/dnsmasq.conf, it is necessary +# to set IGNORE_RESOLVCONF=yes in /etc/default/dnsmasq. + +test -z "$RESOLV_CONF" -a "$IGNORE_RESOLVCONF" != "yes" -a -x /sbin/resolvconf && \ + RESOLV_CONF=/run/dnsmasq/resolv.conf + +start_resolvconf() +{ + if [ "$IGNORE_RESOLVCONF" != "yes" -a -x /sbin/resolvconf ] + then + echo "nameserver 127.0.0.1" | /sbin/resolvconf -a lo.$NAME + fi + : +} + +stop_resolvconf() +{ + if [ "$IGNORE_RESOLVCONF" != "yes" -a -x /sbin/resolvconf ] + then + /sbin/resolvconf -d lo.$NAME + fi + : +} + case "$1" in start) echo -n "starting $DESC: $NAME... " test -d /var/lib/misc/ || mkdir /var/lib/misc/ - start-stop-daemon -S -x $DAEMON -- $ARGS + start-stop-daemon -S -x $DAEMON -- $ARGS \ + ${RESOLV_CONF:+ -r $RESOLV_CONF} \ + ${PIDFILE:+ -x $PIDFILE} + test $? -eq 0 && start_resolvconf echo "done." ;; stop) echo -n "stopping $DESC: $NAME... " + stop_resolvconf start-stop-daemon -K -x $DAEMON echo "done." ;; @@ -25,7 +78,7 @@ case "$1" in start-stop-daemon -q -K -t -x $DAEMON RET=$? if [ "$RET" = "0" ]; then - PID=`cat /var/run/dnsmasq.pid` + PID=`cat ${PIDFILE}` echo "($PID) is running" else echo "is not running" @@ -43,6 +96,18 @@ case "$1" in killall -HUP $(basename ${DAEMON}) echo "done." ;; + systemd-start-resolvconf) + start_resolvconf + ;; + systemd-stop-resolvconf) + stop_resolvconf + ;; + systemd-exec) + test -d /var/lib/misc/ || mkdir /var/lib/misc/ + exec $DAEMON --keep-in-foreground $ARGS \ + ${RESOLV_CONF:+ -r $RESOLV_CONF} \ + ${PIDFILE:+ -x $PIDFILE} + ;; *) echo "Usage: $0 {start|stop|status|restart|reload}" exit 1 |