Subversion Repositories livecd

Rev

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

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