This commit was manufactured by cvs2svn to create tag
[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 DOMFILE=$ROOT/etc/defaultdomain
14 CONFIGFILE=$ROOT/etc/sysconfig/network/config
15 CONFIGFILETMP=$ROOT/etc/sysconfig/network/config.tmp
16 MODCONFFILE=$ROOT/etc/modules.conf
17 MODCONFFILETMP=$ROOT/etc/modules.conf.tmp
18 # INSTALLINF=netsetup.inf
19 # INSTALLINF=install.inf
20 # CHANDEVCONF=chandev.conf
21 # DEVICEDIR=
22 # ROUTINGFILE=routes
23 #
24 #
25 if [ -f $INSTALLINF ]
26 then
27 #       Check for chandev
28 #       CHANDEV=`grep Chandev: $INSTALLINF | uniq | sed -e 's/Chandev: \\(.*\\)/\\1/'`
29 #       [ -n "$CHANDEV" ] && echo $CHANDEV >> $CHANDEVCONF
30 #
31 #       Create modules.conf Entry (alias)
32 #
33         MODCONF=`grep Alias: $INSTALLINF | uniq | sed -e 's/Alias: \\(.*\\)/\\1/'`
34         if [ -n "$MODCONF" ]
35         then
36                 set -- $MODCONF
37                 if [ $# -eq 2 ]
38                 then
39                         egrep "alias[[:space:]]*$1[[:space:]]*" $MODCONFFILE 2>&1 > /dev/null
40                         if [ $? -eq 0 ]
41                         then
42 #                               Entry found
43                                 egrep -v "alias[[:space:]]*$1[[:space:]]*" $MODCONFFILE > $MODCONFFILETMP
44                                 [ $? -eq 0 ] && mv $MODCONFFILETMP $MODCONFFILE
45                                 
46                         fi
47                         echo "alias $MODCONF" >> $MODCONFFILE
48                 fi
49         fi
50 #
51 #       Create modules.conf Entry (Options)
52 #
53         MODCONF=`grep Options: $INSTALLINF | uniq | sed -e 's/Options: \\(.*\\)/\\1/'`
54         if [ -n "$MODCONF" ]
55         then
56                 egrep "options[[:space:]]*$1[[:space:]]*" $MODCONFFILE 2>&1 > /dev/null
57                 if [ $? -eq 0 ]
58                 then
59 #                       Entry found
60                         egrep -v "options[[:space:]]*$1[[:space:]]*" $MODCONFFILE > $MODCONFFILETMP
61                         [ $? -eq 0 ] && mv $MODCONFFILETMP $MODCONFFILE
62                         
63                 fi
64                 echo "options $MODCONF" >> $MODCONFFILE
65         fi
66 #
67 #       Create interfacefile
68 #
69         NETDEV=`grep Netdevice: $INSTALLINF | grep -v sit0 | uniq | sed -e 's/Netdevice: \\(.*\\)/\\1/'`
70         DEVICEFILE=${DEVICEDIR}ifcfg-$NETDEV
71         echo "BOOTPROTO=\"static\"" > $DEVICEFILE
72         echo "STARTMODE=\"onboot\"" >> $DEVICEFILE
73         IP=`grep "^IP:" $INSTALLINF | uniq | sed -e 's/IP: \\(.*\\)/\\1/'`
74         echo "IPADDR=\"$IP\"" >> $DEVICEFILE
75         IP_MTU=`grep "^IP_MTU:" $INSTALLINF | uniq | sed -e 's/IP_MTU: \\(.*\\)/\\1/'`
76         [ -n "$IP_MTU" ] && echo "MTU=\"$IP_MTU\"" >> $DEVICEFILE
77 #
78 #       Create pointopoint Interfaces
79 #
80         PTOP=`grep Pointopoint: $INSTALLINF | uniq | sed -e 's/Pointopoint: \\(.*\\)/\\1/'`
81         [ -n "$PTOP" ] && echo "REMOTE_IPADDR=\"$PTOP\"" >> $DEVICEFILE
82 #
83 #       create broadcast-interface
84 #
85         NWMASK=`grep Netmask: $INSTALLINF | uniq | sed -e 's/Netmask: \\(.*\\)/\\1/'`
86         [ -n "$NWMASK" ] && echo "NETMASK=\"$NWMASK\"" >> $DEVICEFILE
87         NW=`grep Netmask: $INSTALLINF | uniq | sed -e 's/Netmask: \\(.*\\)/\\1/'`
88         [ -n "$NW" ] && echo "NETWORK=\"$NW\"" >> $DEVICEFILE
89         NWBROADCAST=`grep Netmask: $INSTALLINF | uniq | sed -e 's/Netmask: \\(.*\\)/\\1/'`
90         [ -n "$NWBROADCAST" ] && echo "BROADCAST=\"$NWBROADCAST\"" >> $DEVICEFILE
91 #       
92 #       Create routingfile
93 #
94         GW=`grep Gateway: $INSTALLINF | uniq | sed -e 's/Gateway: \\(.*\\)/\\1/'`
95         [ -n "$GW" ] && echo "default $GW 0.0.0.0 $NETDEV" >> $ROUTINGFILE
96 #
97 #       Create /etc/HOSTNAME
98 #
99         HOSTNAME=`grep Machinename: $INSTALLINF | uniq | sed -e 's/Machinename: \\(.*\\)/\\1/'`
100         [ -n "$HOSTNAME" ] && echo "$HOSTNAME" > $HOSTFILE
101 #
102 #       Create /etc/resolv.conf
103 #
104         DOMAIN=`grep Domain: $INSTALLINF | uniq | sed -e 's/Domain: \\(.*\\)/\\1/'`
105         NAMESERVER=`grep Nameserver: $INSTALLINF | uniq | sed -e 's/Nameserver: \\(.*\\)/\\1/'`
106         [ -n "$DOMAIN" ] && echo "domain $DOMAIN" >> $RESFILE
107         [ -n "$NAMESERVER" ] && echo "nameserver $NAMESERVER" >> $RESFILE
108 #
109 #       Create /etc/defaultdomain
110 #
111         [ -n "$DOMAIN" ] && echo "$DOMAIN" >> $DOMFILE
112         WAIT_FOR_INTERFACES=`grep ConnectWait: $INSTALLINF | uniq | sed -e 's/ConnectWait: \\(.*\\)/\\1/'`
113         if [ -n "$WAIT_FOR_INTERFACES" ]
114         then
115 #
116 #       WAIT_FOR_INTERFACES is not zero. Put the value into the file
117 #       We are the first to modify this file. Default is zero
118 #
119                 sed "s/^WAIT_FOR_INTERFACES=.*/WAIT_FOR_INTERFACES=$WAIT_FOR_INTERFACES/" < $CONFIGFILE > $CONFIGFILETMP
120                 [ $? -eq 0 ] && mv $CONFIGFILETMP $CONFIGFILE
121         fi
122         chroot $ROOT chkconfig network on
123 fi
124 :