Subversion Repositories livecd

Rev

Rev 102 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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