Subversion Repositories livecd

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 beyerle@PS 1
#!/bin/bash
2
#
128 beyerle@PS 3
# chkconfig: 345 04 96
4
# description:  Noninteractive HW detection and configuration \
5
#               in particular configure network devices. \
6
#               Used on LiveCD systems.
1 beyerle@PS 7
#
169 beyerle@PS 8
# Urs Beyerle
1 beyerle@PS 9
#
10
 
11
### -----------------------------------------------------------
12
### definitions
13
### -----------------------------------------------------------
14
 
15
# dir of mounted /$MOUNTDIR/live
16
MOUNTDIR=livecd
17
 
18
# source functions
19
. /$MOUNTDIR/live/liblinuxlive
20
. /etc/init.d/functions
21
 
102 beyerle@PS 22
# do not run, if we change runlevels
23
touch /var/lock/subsys/kudzu-auto
1 beyerle@PS 24
 
25
### -----------------------------------------------------------
26
### Get boot parameters
27
### -----------------------------------------------------------
28
 
29
# do not start network
30
NONET=$( cmdline_parameter nonet )
31
 
73 beyerle@PS 32
# static IP
33
IPADDR=$( cmdline_value ip )
1 beyerle@PS 34
 
73 beyerle@PS 35
# gateway
36
GATEWAY=$( cmdline_value gw )
37
 
38
# netmask
39
NETMASK=$( cmdline_value netmask )
40
 
81 beyerle@PS 41
# start WLAN network on boot
42
WLAN=$( cmdline_parameter wlan )
73 beyerle@PS 43
 
81 beyerle@PS 44
# do not apply any fixes (for debugging)
45
NOFIX=$( cmdline_parameter nofix )
46
 
47
 
1 beyerle@PS 48
### -----------------------------------------------------------
144 beyerle@PS 49
### Function start_kudzu_auto
1 beyerle@PS 50
### -----------------------------------------------------------
51
 
144 beyerle@PS 52
start_kudzu_auto() {
1 beyerle@PS 53
 
144 beyerle@PS 54
    ### run kudzu in quiet mode
55
    action $"Hardware auto-detection, please wait... " /usr/sbin/kudzu -q
73 beyerle@PS 56
 
144 beyerle@PS 57
 
58
    ### never start on boot the following network devices (wifi0)
59
    if [ ! $NOFIX ]; then
60
	for iface in wifi0; do
61
	    for file in networking/profiles/default/ifcfg \
62
	        	networking/devices/ifcfg \
63
		        network-scripts/ifcfg; do
64
	      if [ -e /etc/sysconfig/${file}-${iface} ]; then
65
		  sed -i "s/ONBOOT=.*/ONBOOT=no/" /etc/sysconfig/${file}-${iface}
66
	      fi
67
	    done
81 beyerle@PS 68
	done
144 beyerle@PS 69
    fi
73 beyerle@PS 70
 
71
 
144 beyerle@PS 72
    ### do not start network devices, if NONET is defined
73
    if [ $NONET ]; then
74
        # find all network devices (exclude loopback device)
75
	config_files=$( find /etc/sysconfig -name ifcfg-* 2>/dev/null | grep -v ifcfg-lo )
76
	for file in $config_files; do
77
	    sed -i "s/ONBOOT=.*/ONBOOT=no/" $file
78
	done
79
    fi
80
 
1 beyerle@PS 81
 
144 beyerle@PS 82
    ### define static IP and gateway, netmask
83
    if [ $IPADDR ]; then    
84
	if [ ! $GATEWAY ]; then
85
            # default gatway x.y.z.1
86
	    GATEWAY=$( echo $IPADDR | awk -F"." '{ print $1"."$2"."$3".1" }' )
87
	    if [ ! $NETMASK ]; then
88
		NETMASK=255.255.255.0
89
	    fi
73 beyerle@PS 90
	fi
144 beyerle@PS 91
        # create config files for eth0
92
	for iface in eth0; do
93
	    for file in networking/profiles/default/ifcfg \
94
	        	networking/devices/ifcfg \
95
		        network-scripts/ifcfg; do
96
	      sed -i "s/BOOTPROTO=.*/BOOTPROTO=none/" /etc/sysconfig/${file}-${iface}
97
	      echo "IPADDR=$IPADDR" > /etc/sysconfig/${file}-${iface}
98
	      echo "NETMASK=$NETMASK" > /etc/sysconfig/${file}-${iface}
99
	      echo "GATEWAY=$GATEWAY" > /etc/sysconfig/${file}-${iface}
100
	    done
101
	done
73 beyerle@PS 102
    fi
144 beyerle@PS 103
 
104
 
105
    ### activate Atheros WLAN
106
    lspci | grep -q Ethernet.*Atheros
107
    if [ "$?" = "0" ]; then
108
        # bring ath0 up
109
	ifconfig ath0 up > /dev/null 2>&1
110
        # replace wifi0 with ath0
73 beyerle@PS 111
	for file in networking/profiles/default/ifcfg \
112
	            networking/devices/ifcfg \
113
	            network-scripts/ifcfg; do
144 beyerle@PS 114
	  if [ -e /etc/sysconfig/${file}-wifi0 ]; then
115
	      mv /etc/sysconfig/${file}-wifi0 /etc/sysconfig/${file}-ath0
116
	      sed -i "s/wifi0/ath0/" /etc/sysconfig/${file}-ath0
117
	      grep -q Wireless /etc/sysconfig/${file}-ath0
118
	      [ "$?" != "0" ] && echo "TYPE=Wireless" >> /etc/sysconfig/${file}-ath0
119
	  fi
73 beyerle@PS 120
	done
144 beyerle@PS 121
    fi
122
 
123
 
124
    ### configure iwl4965 Intel WLAN Chip
125
    lspci | grep -q Wireless.*4965
114 beyerle@PS 126
    if [ "$?" = "0" ]; then
144 beyerle@PS 127
	find /lib/modules/ 2>&1 | grep -q iwl4965.ko
128
	if [ "$?" = "0" ]; then
129
	    grep -q iwl4965 /etc/modprobe.conf
130
	    if [ "$?" != "0" ]; then
131
		echo "alias wlan0 iwl4965" >> /etc/modprobe.conf
132
	    fi
133
	    if [ ! -e /etc/sysconfig/network-scripts/ifcfg-wlan0 ]; then
134
		cat > /etc/sysconfig/network-scripts/ifcfg-wlan0 <<EOF
114 beyerle@PS 135
TYPE=Wireless
136
DEVICE=wlan0
137
BOOTPROTO=dhcp
138
NETMASK=
139
DHCP_HOSTNAME=
140
IPADDR=
141
DOMAIN=
142
ONBOOT=no
143
USERCTL=no
144
IPV6INIT=no
145
PEERDNS=yes
146
ESSID=
147
CHANNEL=6
148
MODE=Managed
149
RATE=Auto
150
EOF
144 beyerle@PS 151
                ln /etc/sysconfig/network-scripts/ifcfg-wlan0 /etc/sysconfig/networking/devices/ifcfg-wlan0
152
		ln /etc/sysconfig/network-scripts/ifcfg-wlan0 /etc/sysconfig/networking/profiles/default/ifcfg-wlan0 
153
	    fi
114 beyerle@PS 154
	fi
155
    fi
156
 
157
 
144 beyerle@PS 158
    ### do not start WLAN devices on boot
159
    if [ ! $WLAN ]; then
160
        # find all network devices (exclude loopback device)
161
	config_files=$( find /etc/sysconfig -name ifcfg-* 2>/dev/null | grep -v ifcfg-lo )
162
	for file in $config_files; do
163
            # WLAN device?
164
	    grep -q TYPE=Wireless $file
165
	    if [ "$?" = "0" ]; then
166
		sed -i "s/ONBOOT=.*/ONBOOT=no/" $file
167
	    fi
168
	done
169
    fi     
83 beyerle@PS 170
 
144 beyerle@PS 171
}
172
 
173
 
174
### -----------------------------------------------------------
175
### Main
176
### -----------------------------------------------------------
177
 
178
case "$1" in
179
 start)
180
     start_kudzu_auto
181
     ;;
182
 
183
 stop)
184
     ;;
185
 
186
 *)
187
     echo $"Usage: $0 {start|stop}"
188
     exit 1
189
     ;;
190
 
191
esac