- moved all dns related functionality to the plc.d/dns file
[myplc.git] / plc.d / network
index 9df70e4..d5f615f 100755 (executable)
@@ -7,7 +7,7 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # Copyright (C) 2006 The Trustees of Princeton University
 #
-# $Id: network 129 2007-03-20 12:04:03Z thierry $
+# $Id$
 #
 
 # Source function library and configuration
@@ -22,8 +22,9 @@ case "$1" in
        MESSAGE=$"Generating network files"
        dialog "$MESSAGE"
 
+       mv -f /etc/hosts /etc/hosts_plc.backup
+       hfile=$(mktemp)
        # Minimal /etc/hosts
-       echo "127.0.0.1 localhost.localdomain localhost" >/etc/hosts
        (
            for server in DB API BOOT WWW ; do
                hostname=PLC_${server}_HOST
@@ -37,14 +38,22 @@ case "$1" in
                    fi
                fi
            done
-       ) >>/etc/hosts
+       ) > $hfile
+       grep -v "^#" /etc/hosts >> $hfile
+       echo "#generated by /etc/plc.d/network" >/etc/hosts
+       echo "127.0.0.1 localhost.localdomain localhost" >> $hfile
+       sort -u $hfile >> /etc/hosts
+       chmod +r /etc/hosts
+       rm -f $hfile
 
-       # Set up nameservers
-       (
-           [ -n "$PLC_NET_DNS1" ] && echo "nameserver $PLC_NET_DNS1"
-           [ -n "$PLC_NET_DNS2" ] && echo "nameserver $PLC_NET_DNS2"
-       ) >/etc/resolv.conf
+       result "$MESSAGE"
+       ;;
 
+    stop)
+       MESSAGE=$"Reverting network files"
+       if [ -f /etc/hosts_plc.backup ] ; then
+           mv -f /etc/hosts_plc.backup /etc/hosts
+       fi
        result "$MESSAGE"
        ;;
 esac