X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plc.d%2Fnetwork;h=f2c3dce569ebcf1d7419094702d43928c75f59b7;hb=ac6e04e7471b64c2b150d540f90bbd4b6c27e4d5;hp=88ffec0a3c53325a8fd904a509475c908e72bbf9;hpb=b8aaf8fbaf7937e064b6365368b4033546b9a4e3;p=myplc.git diff --git a/plc.d/network b/plc.d/network index 88ffec0..f2c3dce 100755 --- a/plc.d/network +++ b/plc.d/network @@ -7,36 +7,53 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: network,v 1.2 2006/04/25 21:18:19 mlhuang Exp $ +# $Id$ # # Source function library and configuration . /etc/plc.d/functions . /etc/planetlab/plc_config +# Be verbose +set -x + +[ "$PLC_NET_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 - echo "127.0.0.1 localhost.localdomain localhost" >/etc/hosts - ( - for server in API BOOT WWW ; do - hostname=PLC_${server}_HOST + 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 - ) >>/etc/hosts + fi + done > $hfile + echo "#generated by /etc/plc.d/network" >/etc/hosts + 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 - ( - [ -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 + dialog "$MESSAGE" result "$MESSAGE" ;; esac