- extended create_interface to write hostname and resolv.conf
[opensuse:installation-images.git] / data / root / etc / create_interface
1 #!/bin/sh
2 #
3 #       Create interface
4 #       Create chandev-Entry
5 #
6 ROOT=$1
7 INSTALLINF=/etc/install.inf
8 CHANDEVCONF=$ROOT/etc/chandev.conf
9 DEVICEDIR=$ROOT/etc/sysconfig/network/
10 ROUTINGFILE=$ROOT/etc/sysconfig/network/routes
11 HOSTFILE=$ROOT/etc/HOSTNAME
12 RESFILE=$ROOT/etc/resolv.conf
13 # INSTALLINF=netsetup.inf
14 # INSTALLINF=install.inf
15 # CHANDEVCONF=chandev.conf
16 # DEVICEDIR=
17 # ROUTINGFILE=routes
18 #
19 #
20 if [ -f $INSTALLINF ]
21 then
22 #       Check for chandev
23         CHANDEV=`grep Chandev: $INSTALLINF | uniq | sed -e 's/Chandev: \\(.*\\)/\\1/'`
24         if [ ! -z "$CHANDEV" ]
25         then
26                 echo $CHANDEV >> $CHANDEVCONF
27         fi
28 #
29 #       Create interfacefile
30 #
31         NETDEV=`grep Netdevice: $INSTALLINF | uniq | sed -e 's/Netdevice: \\(.*\\)/\\1/'`
32         DEVICEFILE=${DEVICEDIR}ifcfg-$NETDEV
33         echo "BOOTPROTO=\"static\"" > $DEVICEFILE
34         echo "STARTMODE=\"onboot\"" >> $DEVICEFILE
35         IP=`grep "^IP:" $INSTALLINF | uniq | sed -e 's/IP: \\(.*\\)/\\1/'`
36         echo "IPADDR=\"$IP\"" >> $DEVICEFILE
37 #
38 #       Create pointopoint Interfaces
39 #
40         PTOP=`grep Pointopoint: $INSTALLINF | uniq | sed -e 's/Pointopoint: \\(.*\\)/\\1/'`
41         if [ ! -z "$PTOP" ]
42         then
43                 echo "REMOTE_IPADDR=\"$PTOP\"" >> $DEVICEFILE
44         fi
45 #
46 #       create broadcast-interface
47 #
48         NWMASK=`grep Netmask: $INSTALLINF | uniq | sed -e 's/Netmask: \\(.*\\)/\\1/'`
49         if [ ! -z "$NWMASK" ]
50         then
51                 echo "NETMASK=\"$NWMASK\"" >> $DEVICEFILE
52         fi
53         NW=`grep Netmask: $INSTALLINF | uniq | sed -e 's/Netmask: \\(.*\\)/\\1/'`
54         if [ ! -z "$NW" ]
55         then
56                 echo "NETWORK=\"$NW\"" >> $DEVICEFILE
57         fi
58         NWBROADCAST=`grep Netmask: $INSTALLINF | uniq | sed -e 's/Netmask: \\(.*\\)/\\1/'`
59         if [ ! -z "$NWBROADCAST" ]
60         then
61                 echo "BROADCAST=\"$NWBROADCAST\"" >> $DEVICEFILE
62         fi
63 #       
64 #       Create routingfile
65 #
66         GW=`grep Gateway: $INSTALLINF | uniq | sed -e 's/Gateway: \\(.*\\)/\\1/'`
67         if [ ! -z "$GW" ]
68         then
69                 echo "default $GW 0.0.0.0 -" >> $ROUTINGFILE
70         fi
71 #
72 #       Create /etc/HOSTNAME
73 #
74         HOSTNAME=`grep Machinename: $INSTALLINF | uniq | sed -e 's/Machinename: \\(.*\\)/\\1/'`
75         if [ ! -z "$HOSTNAME" ]
76         then
77                 echo "$HOSTNAME" >> $HOSTFILE
78         fi
79 #
80 #       Create /etc/resolv.conf
81 #
82         DOMAIN=`grep Domain: $INSTALLINF | uniq | sed -e 's/Domain: \\(.*\\)/\\1/'`
83         NAMESERVER=`grep Nameserver: $INSTALLINF | uniq | sed -e 's/Nameserver: \\(.*\\)/\\1/'`
84         if [ ! -z "$DOMAIN" -a ! -z "$NAMESERVER" ]
85         then
86                 echo "domain $DOMAIN" >> $RESFILE
87                 echo "nameserver $NAMESERVER" >> $RESFILE
88         fi
89 fi
90 :