Subversion Repositories livecd

Rev

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

Rev 83 Rev 84
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
 
20
 
21
### -----------------------------------------------------------
21
### -----------------------------------------------------------
22
### Get boot parameters
22
### Get boot parameters
23
### -----------------------------------------------------------
23
### -----------------------------------------------------------
24
 
24
 
25
# do not start network
25
# do not start network
26
NONET=$( cmdline_parameter nonet )
26
NONET=$( cmdline_parameter nonet )
27
 
27
 
28
# static IP
28
# static IP
29
IPADDR=$( cmdline_value ip )
29
IPADDR=$( cmdline_value ip )
30
 
30
 
31
# gateway
31
# gateway
32
GATEWAY=$( cmdline_value gw )
32
GATEWAY=$( cmdline_value gw )
33
 
33
 
34
# netmask
34
# netmask
35
NETMASK=$( cmdline_value netmask )
35
NETMASK=$( cmdline_value netmask )
36
 
36
 
37
# start WLAN network on boot
37
# start WLAN network on boot
38
WLAN=$( cmdline_parameter wlan )
38
WLAN=$( cmdline_parameter wlan )
39
 
39
 
40
# do not apply any fixes (for debugging)
40
# do not apply any fixes (for debugging)
41
NOFIX=$( cmdline_parameter nofix )
41
NOFIX=$( cmdline_parameter nofix )
42
 
42
 
43
 
43
 
44
 
44
 
45
### -----------------------------------------------------------
45
### -----------------------------------------------------------
46
### Main
46
### Main
47
### -----------------------------------------------------------
47
### -----------------------------------------------------------
48
 
48
 
49
### run kudzu in quiet mode
49
### run kudzu in quiet mode
50
action $"Hardware auto-detection, please wait... " /usr/sbin/kudzu -q
50
action $"Hardware auto-detection, please wait... " /usr/sbin/kudzu -q
51
 
51
 
52
 
52
 
53
### never start on boot the following network devices (wifi0)
53
### never start on boot the following network devices (wifi0)
54
if [ ! $NOFIX ]; then
54
if [ ! $NOFIX ]; then
55
    for iface in wifi0; do
55
    for iface in wifi0; do
56
	for file in networking/profiles/default/ifcfg \
56
	for file in networking/profiles/default/ifcfg \
57
	    networking/devices/ifcfg \
57
	    networking/devices/ifcfg \
58
	    network-scripts/ifcfg; do
58
	    network-scripts/ifcfg; do
59
	  if [ -e /etc/sysconfig/${file}-${iface} ]; then
59
	  if [ -e /etc/sysconfig/${file}-${iface} ]; then
60
	      sed -i "s/ONBOOT=.*/ONBOOT=no/" /etc/sysconfig/${file}-${iface}
60
	      sed -i "s/ONBOOT=.*/ONBOOT=no/" /etc/sysconfig/${file}-${iface}
61
	  fi
61
	  fi
62
	done
62
	done
63
    done
63
    done
64
fi
64
fi
65
 
65
 
66
 
66
 
67
### do not start network devices, if NONET is defined
67
### do not start network devices, if NONET is defined
68
if [ $NONET ]; then
68
if [ $NONET ]; then
69
    # find all network devices (exclude loopback device)
69
    # find all network devices (exclude loopback device)
70
    config_files=$( find /etc/sysconfig -name ifcfg-* 2>/dev/null | grep -v ifcfg-lo )
70
    config_files=$( find /etc/sysconfig -name ifcfg-* 2>/dev/null | grep -v ifcfg-lo )
71
    for file in $config_files; do
71
    for file in $config_files; do
72
	sed -i "s/ONBOOT=.*/ONBOOT=no/" $file
72
	sed -i "s/ONBOOT=.*/ONBOOT=no/" $file
73
    done
73
    done
74
fi
74
fi
75
 
75
 
76
 
76
 
77
### define static IP and gateway, netmask
77
### define static IP and gateway, netmask
78
if [ $IPADDR ]; then    
78
if [ $IPADDR ]; then    
79
    if [ ! $GATEWAY ]; then
79
    if [ ! $GATEWAY ]; then
80
	# default gatway x.y.z.1
80
	# default gatway x.y.z.1
81
	GATEWAY=$( echo $IPADDR | awk -F"." '{ print $1"."$2"."$3".1" }' )
81
	GATEWAY=$( echo $IPADDR | awk -F"." '{ print $1"."$2"."$3".1" }' )
82
	if [ ! $NETMASK ]; then
82
	if [ ! $NETMASK ]; then
83
	    NETMASK=255.255.255.0
83
	    NETMASK=255.255.255.0
84
	fi
84
	fi
85
    fi
85
    fi
86
    # create config files for eth0
86
    # create config files for eth0
87
    for iface in eth0; do
87
    for iface in eth0; do
88
	for file in networking/profiles/default/ifcfg \
88
	for file in networking/profiles/default/ifcfg \
89
	            networking/devices/ifcfg \
89
	            networking/devices/ifcfg \
90
	            network-scripts/ifcfg; do
90
	            network-scripts/ifcfg; do
91
	  sed -i "s/BOOTPROTO=.*/BOOTPROTO=none/" /etc/sysconfig/${file}-${iface}
91
	  sed -i "s/BOOTPROTO=.*/BOOTPROTO=none/" /etc/sysconfig/${file}-${iface}
92
	  echo "IPADDR=$IPADDR" > /etc/sysconfig/${file}-${iface}
92
	  echo "IPADDR=$IPADDR" > /etc/sysconfig/${file}-${iface}
93
	  echo "NETMASK=$NETMASK" > /etc/sysconfig/${file}-${iface}
93
	  echo "NETMASK=$NETMASK" > /etc/sysconfig/${file}-${iface}
94
	  echo "GATEWAY=$GATEWAY" > /etc/sysconfig/${file}-${iface}
94
	  echo "GATEWAY=$GATEWAY" > /etc/sysconfig/${file}-${iface}
95
	done
95
	done
96
    done
96
    done
97
fi
97
fi
98
 
98
 
99
 
99
 
100
### activate ipw3945d daemon, if we have Intel IPW3945 WLAN 
-
 
101
lspci | grep -q Intel.*3945ABG
-
 
102
if [ "$?" = "0" ]; then
-
 
103
    chkconfig ipw3945d on 2>/dev/null
-
 
104
    /etc/init.d/ipw3945d start >/dev/null 2>&1 &
-
 
105
fi
-
 
106
 
-
 
107
### activate Atheros WLAN
100
### activate Atheros WLAN
108
lspci | grep -q Ethernet.*Atheros
101
lspci | grep -q Ethernet.*Atheros
109
if [ "$?" = "0" ]; then
102
if [ "$?" = "0" ]; then
110
    # bring ath0 up
103
    # bring ath0 up
111
    ifconfig ath0 up > /dev/null 2>&1
104
    ifconfig ath0 up > /dev/null 2>&1
112
    # replace wifi0 with ath0
105
    # replace wifi0 with ath0
113
    for file in networking/profiles/default/ifcfg \
106
    for file in networking/profiles/default/ifcfg \
114
	networking/devices/ifcfg \
107
	networking/devices/ifcfg \
115
	network-scripts/ifcfg; do
108
	network-scripts/ifcfg; do
116
      if [ -e /etc/sysconfig/${file}-wifi0 ]; then
109
      if [ -e /etc/sysconfig/${file}-wifi0 ]; then
117
	  mv /etc/sysconfig/${file}-wifi0 /etc/sysconfig/${file}-ath0
110
	  mv /etc/sysconfig/${file}-wifi0 /etc/sysconfig/${file}-ath0
118
	  sed -i "s/wifi0/ath0/" /etc/sysconfig/${file}-ath0
111
	  sed -i "s/wifi0/ath0/" /etc/sysconfig/${file}-ath0
119
	  grep -q Wireless /etc/sysconfig/${file}-ath0
112
	  grep -q Wireless /etc/sysconfig/${file}-ath0
120
	  [ "$?" != "0" ] && echo "TYPE=Wireless" >> /etc/sysconfig/${file}-ath0
113
	  [ "$?" != "0" ] && echo "TYPE=Wireless" >> /etc/sysconfig/${file}-ath0
121
      fi
114
      fi
122
    done
115
    done
123
fi
116
fi
124
 
117
 
125
 
118
 
126
### do not start WLAN devices on boot
119
### do not start WLAN devices on boot
127
if [ ! $WLAN ]; then
120
if [ ! $WLAN ]; then
128
    # find all network devices (exclude loopback device)
121
    # find all network devices (exclude loopback device)
129
    config_files=$( find /etc/sysconfig -name ifcfg-* 2>/dev/null | grep -v ifcfg-lo )
122
    config_files=$( find /etc/sysconfig -name ifcfg-* 2>/dev/null | grep -v ifcfg-lo )
130
    for file in $config_files; do
123
    for file in $config_files; do
131
	# WLAN device?
124
	# WLAN device?
132
	grep -q TYPE=Wireless $file
125
	grep -q TYPE=Wireless $file
133
        if [ "$?" = "0" ]; then
126
        if [ "$?" = "0" ]; then
134
	    sed -i "s/ONBOOT=.*/ONBOOT=no/" $file
127
	    sed -i "s/ONBOOT=.*/ONBOOT=no/" $file
135
	fi
128
	fi
136
    done
129
    done
137
fi
130
fi
138
 
131
 
139
    
-
 
140
### enable 915resolution on Intel Mobile Display controller
-
 
141
lspci | grep -q Display.*Intel.*Mobile
-
 
142
if [ "$?" = "0" ]; then 
-
 
143
    chkconfig 915resolution on
-
 
144
    /etc/init.d/915resolution start >/dev/null 2>&1 &
-
 
145
fi
-
 
146
    
-