- split up guest.init (/etc/init.d/plc inside the chroot) into
[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: guest.init,v 1.12 2006/04/04 22:09:47 mlhuang Exp $
11 #
12
13 # Source function library and configuration
14 . /etc/plc.d/functions
15
16 case "$1" in
17     start)
18         MESSAGE=$"Generating network files"
19         dialog "$MESSAGE"
20
21         # Minimal /etc/hosts
22         echo "127.0.0.1 localhost.localdomain localhost" >/etc/hosts
23         (
24             for server in API BOOT WWW ; do
25                 hostname=PLC_${server}_HOST
26                 ip=$(gethostbyname ${!hostname})
27                 if [ -n "$ip" ] ; then
28                     echo "$ip   $hostname"
29                 fi
30             done
31         ) >>/etc/hosts
32
33         # Set up nameservers
34         (
35             [ -n "$PLC_NET_DNS1" ] && echo "nameserver $PLC_NET_DNS1"
36             [ -n "$PLC_NET_DNS2" ] && echo "nameserver $PLC_NET_DNS2"
37         ) >/etc/resolv.conf
38
39         result "$MESSAGE"
40         ;;
41 esac
42
43 exit $ERRORS