Simplify network file setup.
Marc Fiuczynski [Fri, 25 Jan 2008 20:43:36 +0000 (20:43 +0000)]
plc.d/network

index 141bc50..3022e39 100755 (executable)
@@ -51,34 +51,13 @@ case "$1" in
        chmod +r $target
        rm -f $hfile
 
-       rfile=$(mktemp)
        # Set up nameservers
        (
+           echo "; generated by /etc/plc.d/network"
            [ -n "$PLC_NET_DNS1" ] && echo "nameserver $PLC_NET_DNS1"
            [ -n "$PLC_NET_DNS2" -a "$PLC_NET_DNS1" != "$PLC_NET_DNS2" ] && echo "nameserver $PLC_NET_DNS2"
-       ) > $rfile
-
-       if [ $PLC_DNS_ENABLED -eq 1 ] ; then
-           target=/etc/plc_resolv.conf
-
-           r2file=$(mktemp)
-           echo "; generated by /etc/plc.d/network" >$r2file
-           if [ -n "${!PLC_BOOT_IP}" ] ; then
-               echo "nameserver ${!PLC_BOOT_IP}" >>$r2file
-           else
-                   ip=$(gethostbyname ${!PLC_BOOT_HOST})
-                   if [ -n "$ip" ] ; then
-                       echo "nameserver $ip" >>$r2file
-                   fi
-           fi
-           changed=$(diff $r2file /etc/resolv.conf)
-           [ $changed -ne 0 ] && cp /etc/resolv.conf /etc/resolv.conf.bak
-           mv $r2file /etc/resolv.conf
-       else
-           target=/etc/resolv.conf
-       fi
-       mv $rfile $target
-       chmod +r $target
+       ) > /etc/resolv.conf
+       chmod +r /etc/resolv.conf
 
        result "$MESSAGE"
        ;;