#!/bin/bash # # priority: 100 # # Manage network related configuration files # # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # # $Id$ # # Source function library and configuration . /etc/plc.d/functions . /etc/planetlab/plc_config # Be verbose set -x case "$1" in start) MESSAGE=$"Generating network files" dialog "$MESSAGE" 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 fi done ) > $hfile if [ $PLC_DNS_ENABLED -eq 1 ] ; then target=/etc/plc_hosts sort -u $hfile > $target else target=/etc/hosts cat /etc/hosts >> $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 fi chmod +r $target rm -f $hfile rfile=$(mktemp) # Set up nameservers ( [ -n "$PLC_NET_DNS1" ] && echo "nameserver $PLC_NET_DNS1" [ -n "$PLC_NET_DNS2" ] && echo "nameserver $PLC_NET_DNS2" ) > $rfile if [ $PLC_DNS_ENABLED -eq 1 ] ; then target=/etc/plc_resolv.conf else target=/etc/resolv.conf fi cp $rfile $target chmod +r $target result "$MESSAGE" ;; esac exit $ERRORS