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