Subversion Repositories livecd

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 beyerle@PS 1
#!/bin/bash
2
#
3
# Noninteractive HW detection and configuration
73 beyerle@PS 4
# in particular configure network devices
1 beyerle@PS 5
#
6
# Urs Beyerle, PSI
7
#
8
 
9
### -----------------------------------------------------------
10
### definitions
11
### -----------------------------------------------------------
12
 
13
# dir of mounted /$MOUNTDIR/live
14
MOUNTDIR=livecd
15
 
16
# source functions
17
. /$MOUNTDIR/live/liblinuxlive
18
. /etc/init.d/functions
19
 
20
 
21
### -----------------------------------------------------------
22
### Get boot parameters
23
### -----------------------------------------------------------
24
 
25
# do not start network
26
NONET=$( cmdline_parameter nonet )
27
 
73 beyerle@PS 28
# static IP
29
IPADDR=$( cmdline_value ip )
1 beyerle@PS 30
 
73 beyerle@PS 31
# gateway
32
GATEWAY=$( cmdline_value gw )
33
 
34
# netmask
35
NETMASK=$( cmdline_value netmask )
36
 
81 beyerle@PS 37
# start WLAN network on boot
38
WLAN=$( cmdline_parameter wlan )
73 beyerle@PS 39
 
81 beyerle@PS 40
# do not apply any fixes (for debugging)
41
NOFIX=$( cmdline_parameter nofix )
42
 
43
 
44
 
1 beyerle@PS 45
### -----------------------------------------------------------
46
### Main
47
### -----------------------------------------------------------
48
 
73 beyerle@PS 49
### run kudzu in quiet mode
1 beyerle@PS 50
action $"Hardware auto-detection, please wait... " /usr/sbin/kudzu -q
51
 
73 beyerle@PS 52
 
81 beyerle@PS 53
### never start on boot the following network devices (wifi0)
54
if [ ! $NOFIX ]; then
55
    for iface in wifi0; do
56
	for file in networking/profiles/default/ifcfg \
57
	    networking/devices/ifcfg \
58
	    network-scripts/ifcfg; do
59
	  if [ -e /etc/sysconfig/${file}-${iface} ]; then
60
	      sed -i "s/ONBOOT=.*/ONBOOT=no/" /etc/sysconfig/${file}-${iface}
61
	  fi
62
	done
73 beyerle@PS 63
    done
81 beyerle@PS 64
fi
73 beyerle@PS 65
 
66
 
81 beyerle@PS 67
### do not start network devices, if NONET is defined
1 beyerle@PS 68
if [ $NONET ]; then
73 beyerle@PS 69
    # find all network devices (exclude loopback device)
70
    config_files=$( find /etc/sysconfig -name ifcfg-* 2>/dev/null | grep -v ifcfg-lo )
71
    for file in $config_files; do
72
	sed -i "s/ONBOOT=.*/ONBOOT=no/" $file
1 beyerle@PS 73
    done
74
fi
75
 
73 beyerle@PS 76
 
77
### define static IP and gateway, netmask
78
if [ $IPADDR ]; then    
79
    if [ ! $GATEWAY ]; then
80
	# default gatway x.y.z.1
81
	GATEWAY=$( echo $IPADDR | awk -F"." '{ print $1"."$2"."$3".1" }' )
82
	if [ ! $NETMASK ]; then
83
	    NETMASK=255.255.255.0
84
	fi
85
    fi
86
    # create config files for eth0
87
    for iface in eth0; do
88
	for file in networking/profiles/default/ifcfg \
89
	            networking/devices/ifcfg \
90
	            network-scripts/ifcfg; do
91
	  sed -i "s/BOOTPROTO=.*/BOOTPROTO=none/" /etc/sysconfig/${file}-${iface}
92
	  echo "IPADDR=$IPADDR" > /etc/sysconfig/${file}-${iface}
93
	  echo "NETMASK=$NETMASK" > /etc/sysconfig/${file}-${iface}
94
	  echo "GATEWAY=$GATEWAY" > /etc/sysconfig/${file}-${iface}
95
	done
96
    done
97
fi
98
 
99
 
100
### activate ipw3945d daemon, if we have Intel IPW3945 WLAN 
101
lspci | grep -q Intel.*3945ABG
102
[ "$?" = "0" ] && chkconfig ipw3945d on 2>/dev/null
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
 
81 beyerle@PS 124
### do not start WLAN devices on boot
125
if [ ! $WLAN ]; then
126
    # find all network devices (exclude loopback device)
127
    config_files=$( find /etc/sysconfig -name ifcfg-* 2>/dev/null | grep -v ifcfg-lo )
128
    for file in $config_files; do
129
	# WLAN device?
130
	grep -q TYPE=Wireless $file
131
        if [ "$?" = "0" ]; then
132
	    sed -i "s/ONBOOT=.*/ONBOOT=no/" $file
133
	fi
134
    done
135
fi
136
 
137
 
75 beyerle@PS 138
### enable 915resolution on Intel Mobile Display controller
139
lspci | grep -q Display.*Intel.*Mobile
140
[ "$?" = "0" ] && chkconfig 915resolution on
141