Fix dnsmasq dbus suppport for NetBSD.
authorRoy Marples <roy@marples.name>
Thu, 6 Mar 2008 16:26:59 +0000 (16:26 +0000)
committerRoy Marples <roy@marples.name>
Thu, 6 Mar 2008 16:26:59 +0000 (16:26 +0000)
dnsmasq.in

index 2bf6e45f8416b7073798c20103c4789c94909a57..b26973d34a0fd10533618e42566e4de5f2172fac 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/sh
-# Copyright 2007 Roy Marples
+# Copyright 2007-2008 Roy Marples
 # All rights reserved
 
 # dnsmasq subscriber for resolvconf
@@ -55,6 +55,7 @@ eval "${VARS}"
 PREFIX=@PREFIX@
 DNSMASQRESOLV="${PREFIX}/etc/dnsmasq-resolv.conf"
 DNSMASQCONF="${PREFIX}/etc/dnsmasq-resolvconf.conf"
+DNSMASQPID=/var/run/dnsmasq.pid
 
 NEWCONF="# Generated by resolvconf\n"
 NEWRESOLV="${NEWCONF}"
@@ -65,15 +66,16 @@ NEWRESOLV="${NEWCONF}"
 # so we need to validate a few things first.
 # Check for DBus support in the binary
 DBUS=no
-dbuspid=/var/run/dbus/dbus.pid
-[ -s "${dbuspid}" ] || dbuspid=/var/run/dbus.pid
-if [ -s "${dbuspid}" -a -s /var/run/dnsmasq.pid ]; then
+DBUSPID=/var/run/dbus/dbus.pid
+[ -s "${DBUSPID}" ] || DBUSPID=/var/run/dbus.pid
+[ -s "${DBUSPID}" ] || DBUSPID=/var/run/dbus/pid
+if [ -s "${DBUSPID}" -a -s ${DNSMASQPID} ]; then
        if dnsmasq --version 2>/dev/null | \
                grep -q "^Compile time options.*[[:space:]]DBus[[:space:]]" \
                ; then
                # Sanity - check that dnsmasq and dbus are running
-               if kill -0 $(cat "${dbuspid}") 2>/dev/null \
-                       && kill -0 $(cat /var/run/dnsmasq.pid) 2>/dev/null; then
+               if kill -0 $(cat "${DBUSPID}") 2>/dev/null \
+                       && kill -0 $(cat ${DNSMASQPID}) 2>/dev/null; then
                        DBUS=yes
                        NEWCONF="${NEWCONF}\n# Domain specific servers will be sent over dbus\nenable-dbus\n"
                fi
@@ -154,8 +156,8 @@ fi
 
 [ "${RELOAD}" = "yes" ] && resolvconf -s dnsmasq restart
 if [ "${DBUS}" = "yes" ]; then
-       [ "${RELOAD}" != "yes" ] && resolvconf -s dnsmasq reload
-       # Send even if emtpy so old servers are cleared
+       [ "${RELOAD}" != "yes" ] && kill -HUP $(cat ${DNSMASQPID})
+       # Send even if empty so old servers are cleared
        dbus-send --system --dest=uk.org.thekelleys.dnsmasq \
                /uk/org/thekelleys/dnsmasq uk.org.thekelleys.SetServers \
                ${DBUSDEST}