:: Re: [DNG] dnsmaq on devuan
トップ ページ
このメッセージを削除
このメッセージに返信
著者: Irrwahn
日付:  
To: dng
題目: Re: [DNG] dnsmaq on devuan
John Crisp wrote on 23.03.2018 02:22:
> I have been having some struggles running dnsmasq on Devuan Jessie.
>
> After a lot of head scratching I started to realise the init file seems
> a touch out of whack. For starters, no pid file is generated when you
> start dnsmasq.
>
> There I was thinking I was stopping and starting it when in reality, I
> was just adding more instances ! That would then explain why the new
> settings I kept trying seemed to fail miserably. Doh <slapshead>
>
> I do not have resolvconf installed.
>
> dnsmasq 2.72-3+deb8u2
>
> I just wanted a simple caching nameserver for VPN clients with some
> simple static upstream DNS nameservers set.
>
> I can sit down and slowly debug my way through the init file but
> wondered if anyone else had any experiences with this?



Hi John,

I routinely have dnsmasq running on my Devuan ASCII box (was running
Debian testing/jessie before) and never observed any irregularities.
I checked and the PID file is correctly maintained, issuing service
start/stop/status commands works as expected. (dnsmasq 2.76-5+deb9u1)

For comparison I tested again on a Devuan Jessie VM (dnsmasq version
2.72-3+deb8u2, same as yours) with identical positive results. No
resolvconf installed on both systems.
The dnsmasq init scripts in Jessie and ASCII differ basically just in
the relocation /var/run --> /run. But since the former should be just
a symlink to the latter on both systems it should not have any
noticeable effect at all. For reference I attached a diff between the
two versions.

Whatever causes you trouble, I strongly believe it's not the dnsmasq
init script per se that is to blame.

Sorry I cannot provide you with an instant solution for your problem.

HTH, best regards
Urban

P.S.:
Yes, I too find the file time stamps in the diff slightly irritating,
but I double checked I was comparing the correct files. I did not
inspect the respective source packages though.

--
Sapere aude!
--- dnsmasq.jessie    2017-10-01 19:17:30.000000000 +0200
+++ dnsmasq.ascii    2017-10-01 17:20:45.000000000 +0200
@@ -8,7 +8,8 @@
 # Description:    DHCP and DNS server
 ### END INIT INFO


-set +e # Don't exit on error status
+# Don't exit on error status
+set +e

 PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 DAEMON=/usr/sbin/dnsmasq
@@ -29,12 +30,11 @@
         export LANG
 fi


-# /etc/dnsmasq.d/README is a non-conffile installed by the dnsmasq package.
-# Should the dnsmasq package be removed, the following test ensures that
-# the daemon is no longer started, even if the dnsmasq-base package is
-# still in place.
-test -e /etc/dnsmasq.d/README || exit 0
-
+# The following test ensures the dnsmasq service is not started, when the
+# package 'dnsmasq' is removed but not purged, even if the dnsmasq-base
+# package is still in place.
+test -e /usr/share/dnsmasq/installed-marker || exit 0
+
test -x $DAEMON || exit 0

 # Provide skeleton LSB log functions for backports which don't have LSB functions.
@@ -81,7 +81,7 @@
    [ "$IGNORE_RESOLVCONF" != "yes" ] &&
    [ -x /sbin/resolvconf ]
 then
-    RESOLV_CONF=/var/run/dnsmasq/resolv.conf
+    RESOLV_CONF=/run/dnsmasq/resolv.conf
 fi


 for INTERFACE in $DNSMASQ_INTERFACE; do
@@ -121,16 +121,16 @@
     #   1 if daemon was already running
     #   2 if daemon could not be started


-        # /var/run may be volatile, so we need to ensure that
-        # /var/run/dnsmasq exists here as well as in postinst
-        if [ ! -d /var/run/dnsmasq ]; then
-           mkdir /var/run/dnsmasq || return 2
-           chown dnsmasq:nogroup /var/run/dnsmasq || return 2
+        # /run may be volatile, so we need to ensure that
+        # /run/dnsmasq exists here as well as in postinst
+        if [ ! -d /run/dnsmasq ]; then
+           mkdir /run/dnsmasq || return 2
+           chown dnsmasq:nogroup /run/dnsmasq || return 2
         fi


-    start-stop-daemon --start --quiet --pidfile /var/run/dnsmasq/$NAME.pid --exec $DAEMON --test > /dev/null || return 1
-    start-stop-daemon --start --quiet --pidfile /var/run/dnsmasq/$NAME.pid --exec $DAEMON -- \
-        -x /var/run/dnsmasq/$NAME.pid \
+    start-stop-daemon --start --quiet --pidfile /run/dnsmasq/$NAME.pid --exec $DAEMON --test > /dev/null || return 1
+    start-stop-daemon --start --quiet --pidfile /run/dnsmasq/$NAME.pid --exec $DAEMON -- \
+        -x /run/dnsmasq/$NAME.pid \
             ${MAILHOSTNAME:+ -m $MAILHOSTNAME} \
         ${MAILTARGET:+ -t $MAILTARGET} \
         ${DNSMASQ_USER:+ -u $DNSMASQ_USER} \
@@ -167,7 +167,7 @@
     #   1 if daemon was already stopped
     #   2 if daemon could not be stopped
     #   other if a failure occurred
-    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile /var/run/dnsmasq/$NAME.pid --name $NAME
+    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile /run/dnsmasq/$NAME.pid --name $NAME
 }


 stop_resolvconf()
@@ -185,9 +185,9 @@
     #   1 if daemon is dead and pid file exists
     #   3 if daemon is not running
     #   4 if daemon status is unknown
-    start-stop-daemon --start --quiet --pidfile /var/run/dnsmasq/$NAME.pid --exec $DAEMON --test > /dev/null
+    start-stop-daemon --start --quiet --pidfile /run/dnsmasq/$NAME.pid --exec $DAEMON --test > /dev/null
     case "$?" in
-        0) [ -e "/var/run/dnsmasq/$NAME.pid" ] && return 1 ; return 3 ;;
+        0) [ -e "/run/dnsmasq/$NAME.pid" ] && return 1 ; return 3 ;;
         1) return 0 ;;
         *) return 4 ;;
     esac
@@ -278,7 +278,7 @@
     esac
     ;;
   dump-stats)
-        kill -s USR1 `cat /var/run/dnsmasq/$NAME.pid`
+        kill -s USR1 `cat /run/dnsmasq/$NAME.pid`
     ;;
   systemd-start-resolvconf)
     start_resolvconf
@@ -287,13 +287,13 @@
     stop_resolvconf
     ;;
   systemd-exec)
-# /var/run may be volatile, so we need to ensure that
-        # /var/run/dnsmasq exists here as well as in postinst
-        if [ ! -d /var/run/dnsmasq ]; then
-           mkdir /var/run/dnsmasq || return 2
-           chown dnsmasq:nogroup /var/run/dnsmasq || return 2
+# /run may be volatile, so we need to ensure that
+        # /run/dnsmasq exists here as well as in postinst
+        if [ ! -d /run/dnsmasq ]; then
+           mkdir /run/dnsmasq || return 2
+           chown dnsmasq:nogroup /run/dnsmasq || return 2
         fi
-    exec $DAEMON -x /var/run/dnsmasq/$NAME.pid \
+    exec $DAEMON -x /run/dnsmasq/$NAME.pid \
         ${MAILHOSTNAME:+ -m $MAILHOSTNAME} \
         ${MAILTARGET:+ -t $MAILTARGET} \
         ${DNSMASQ_USER:+ -u $DNSMASQ_USER} \