Help dnsmasq configuration to make sense.
authorDaniel Hokka Zakrisson <dhokka@cs.princeton.edu>
Thu, 18 Nov 2010 04:31:36 +0000 (23:31 -0500)
committerDaniel Hokka Zakrisson <dhokka@cs.princeton.edu>
Thu, 18 Nov 2010 04:31:36 +0000 (23:31 -0500)
plc.d/dns

index 1840f32..361d639 100755 (executable)
--- a/plc.d/dns
+++ b/plc.d/dns
@@ -43,19 +43,24 @@ case "$1" in
            ) > $rfile
            
            if [ $PLC_DNS_ENABLED -eq 1 ] ; then
+               cp $rfile /etc/plc_resolv.conf
+               chmod 444 /etc/plc_resolv.conf
                ourfile=$(grep "$SIGNATURE" /etc/resolv.conf| wc -l)
                if [ $ourfile -eq 0 ] ; then
-                   cp /etc/resolv.conf /etc/plc_resolv.conf
+                   cp /etc/resolv.conf /etc/resolv.bak
+                   echo $SIGNATURE > /etc/resolv.conf
+                   echo nameserver 127.0.0.1 >> /etc/resolv.conf
+                   chmod 444 /etc/resolv.conf
                fi
            else
-               cp /etc/resolv.conf /etc/resolv_plc.backup
+               cp /etc/resolv.conf /etc/resolv.bak
+               mv -f $rfile /etc/resolv.conf
+               chmod 444 /etc/resolv.conf
            fi
-           mv -f $rfile /etc/resolv.conf
-           chmod 444 /etc/resolv.conf
        fi
 
        if [ $PLC_DNS_ENABLED -eq 1 ] ; then
-           plc_daemon dnsmasq
+           plc_daemon dnsmasq -r /etc/plc_resolv.conf
            check
        fi
 
@@ -63,29 +68,23 @@ case "$1" in
        ;;
 
     stop)
-       if [ $PLC_DNS_ENABLED -eq 1 ] ; then
-           MESSAGE=$"Reverting /etc/resolv.conf"
-           dialog "$MESSAGE"
-           if [ -f "/etc/plc_resolv.conf" ] ; then
-               ourfile=$(grep "$SIGNATURE" /etc/plc_resolv.conf| wc -l)
-               if [ $ourfile -ne 0 ] ; then 
-                   dialog "WARNING: original /etc/resolv.conf was generated by etc/plc.d/dns"          
-               fi
-               mv -f /etc/plc_resolv.conf /etc/resolv.conf
+       MESSAGE=$"Reverting /etc/resolv.conf"
+       dialog "$MESSAGE"
+       if [ -f "/etc/resolv.bak" ] ; then
+           ourfile=$(grep "$SIGNATURE" /etc/resolv.bak | wc -l)
+           if [ $ourfile -ne 0 ] ; then 
+               dialog "WARNING: original /etc/resolv.conf was generated by etc/plc.d/dns"              
            fi
-           check
-           result ""
+           mv -f /etc/resolv.bak /etc/resolv.conf
+       fi
+       check
+       result ""
+       if [ $PLC_DNS_ENABLED -eq 1 ] ; then
            MESSAGE=$"Removing /etc/plc_hosts"
            dialog "$MESSAGE"
            [ -f "/etc/plc_hosts" ] && rm -f /etc/plc_hosts
            result ""
        fi
-       if [ $PLC_DNS_ENABLED -eq 0 -a -f "/etc/resolv_plc.backup" ] ; then
-           MESSAGE="Restoring /etc/resolv.conf"
-           dialog "$MESSAGE"
-           mv -f /etc/resolv_plc.backup /etc/resolv.conf
-           result ""
-       fi
 
        if [ $PLC_DNS_ENABLED -eq 1 ] ; then
            MESSAGE="Stopping DNS server"