- fix /etc/hosts generation
[myplc.git] / plc.d / network
1 #!/bin/bash
2 #
3 # priority: 100
4 #
5 # Manage network related configuration files
6 #
7 # Mark Huang <mlhuang@cs.princeton.edu>
8 # Copyright (C) 2006 The Trustees of Princeton University
9 #
10 # $Id: network,v 1.2 2006/04/25 21:18:19 mlhuang Exp $
11 #
12
13 # Source function library and configuration
14 . /etc/plc.d/functions
15 . /etc/planetlab/plc_config
16
17 case "$1" in
18     start)
19         MESSAGE=$"Generating network files"
20         dialog "$MESSAGE"
21
22         # Minimal /etc/hosts
23         echo "127.0.0.1 localhost.localdomain localhost" >/etc/hosts
24         (
25             for server in API BOOT WWW ; do
26                 hostname=PLC_${server}_HOST
27                 ip=$(gethostbyname ${!hostname})
28                 if [ -n "$ip" ] ; then
29                     echo "$ip   ${!hostname}"
30                 fi
31             done
32         ) >>/etc/hosts
33
34         # Set up nameservers
35         (
36             [ -n "$PLC_NET_DNS1" ] && echo "nameserver $PLC_NET_DNS1"
37             [ -n "$PLC_NET_DNS2" ] && echo "nameserver $PLC_NET_DNS2"
38         ) >/etc/resolv.conf
39
40         result "$MESSAGE"
41         ;;
42 esac
43
44 exit $ERRORS