Document setting /etc/resolv.conf to list the local nameserver.
[openresolv] / dnsmasq.in
index ee4a6d682044ef011a281ece70bb38e2eb1d01aa..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
@@ -40,8 +40,8 @@
 # NOTE: The loopback interface on some systems maybe lo0.
 #domain-needed
 #interface=lo
-#resolv-file=/etc/dnsmasq-resolv.conf
-#conf-file=/etc/dnsmasq-resolvconf.conf
+#resolv-file=@PREFIX@/etc/dnsmasq-resolv.conf
+#conf-file=@PREFIX@/etc/dnsmasq-resolvconf.conf
 
 # The last step is to configure dns configuration for /etc/resolv.conf
 # for the lo interface. You can do this in resolvconf as well by adding
 VARS="$(resolvconf -v)"
 eval "${VARS}"
 
-PREFIX=
+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}") \
-                       && kill -0 $(cat /var/run/dnsmasq.pid); 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,11 +156,9 @@ 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}
 fi
-
-# vim: ts=4 :