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
#
8
# Urs Beyerle, PSI
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
 
102 beyerle@PS 25
 
1 beyerle@PS 26
### -----------------------------------------------------------
27
### Get boot parameters
28
### -----------------------------------------------------------
29
 
30
# do not start network
31
NONET=$( cmdline_parameter nonet )
32
 
73 beyerle@PS 33
# static IP
34
IPADDR=$( cmdline_value ip )
1 beyerle@PS 35
 
73 beyerle@PS 36
# gateway
37
GATEWAY=$( cmdline_value gw )
38
 
39
# netmask
40
NETMASK=$( cmdline_value netmask )
41
 
81 beyerle@PS 42
# start WLAN network on boot
43
WLAN=$( cmdline_parameter wlan )
73 beyerle@PS 44
 
81 beyerle@PS 45
# do not apply any fixes (for debugging)
46
NOFIX=$( cmdline_parameter nofix )
47
 
48
 
49
 
1 beyerle@PS 50
### -----------------------------------------------------------
51
### Main
52
### -----------------------------------------------------------
53
 
73 beyerle@PS 54
### run kudzu in quiet mode
1 beyerle@PS 55
action $"Hardware auto-detection, please wait... " /usr/sbin/kudzu -q
56
 
73 beyerle@PS 57
 
81 beyerle@PS 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
73 beyerle@PS 68
    done
81 beyerle@PS 69
fi
73 beyerle@PS 70
 
71
 
81 beyerle@PS 72
### do not start network devices, if NONET is defined
1 beyerle@PS 73
if [ $NONET ]; then
73 beyerle@PS 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
1 beyerle@PS 78
    done
79
fi
80
 
73 beyerle@PS 81
 
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
90
    fi
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
102
fi
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
81 beyerle@PS 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
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
120
    done
75 beyerle@PS 121
fi
122
 
123
 
114 beyerle@PS 124
### configure iwl4965 Intel WLAN Chip
125
lspci | grep -q Wireless.*4965
126
if [ "$?" = "0" ]; then
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
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
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
154
    fi
155
fi
156
 
157
 
81 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