X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plc.d%2Fnetwork;h=363a0f671402f28ed450cbbefc25ed6abb6d45e5;hb=2ae81168869377bdc861adb055206f41dd4c1ce4;hp=6fac27b56b2b46eea88d6792c88d089c99568b4d;hpb=dd1b3ead87960bb3e9f0b5582711a0b0c2abd601;p=myplc.git diff --git a/plc.d/network b/plc.d/network index 6fac27b..363a0f6 100755 --- a/plc.d/network +++ b/plc.d/network @@ -7,8 +7,6 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id$ -# # Source function library and configuration . /etc/plc.d/functions @@ -17,42 +15,43 @@ # Be verbose set -x +[ "$PLC_HOSTS_ENABLED" -ne 1 ] && exit 0 + case "$1" in start) MESSAGE=$"Generating network files" dialog "$MESSAGE" + mv -f /etc/hosts /etc/hosts_plc.backup hfile=$(mktemp) # Minimal /etc/hosts - ( - for server in DB API BOOT WWW ; do - hostname=PLC_${server}_HOST - ip=PLC_${server}_IP - if [ -n "${!ip}" ] ; then - echo "${!ip} ${!hostname}" - else - ip=$(gethostbyname ${!hostname}) - if [ -n "$ip" ] ; then - echo "$ip ${!hostname}" - fi + for server in DB API BOOT WWW ; do + hostname=PLC_${server}_HOST + ip=PLC_${server}_IP + if [ -n "${!ip}" ] ; then + echo "${!ip} ${!hostname}" + else + ip=$(gethostbyname ${!hostname}) + if [ -n "$ip" ] ; then + echo "$ip ${!hostname}" fi - done - ) > $hfile - grep -v "^#" /etc/hosts >> $hfile + fi + done > $hfile echo "#generated by /etc/plc.d/network" >/etc/hosts - echo "127.0.0.1 localhost.localdomain localhost" >> $hfile + echo "127.0.0.1 localhost.localdomain localhost" >> /etc/hosts sort -u $hfile >> /etc/hosts chmod +r /etc/hosts rm -f $hfile - # 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" - ) > /etc/resolv.conf - chmod +r /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 + dialog "$MESSAGE" result "$MESSAGE" ;; esac