Subversion Repositories livecd

Rev

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

Rev 73 Rev 75
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
 
37
 
38
### -----------------------------------------------------------
38
### -----------------------------------------------------------
39
### Main
39
### Main
40
### -----------------------------------------------------------
40
### -----------------------------------------------------------
41
 
41
 
42
### run kudzu in quiet mode
42
### run kudzu in quiet mode
43
action $"Hardware auto-detection, please wait... " /usr/sbin/kudzu -q
43
action $"Hardware auto-detection, please wait... " /usr/sbin/kudzu -q
44
 
44
 
45
 
45
 
46
### never start on boot the following network devices (wifi0, ath0)
46
### never start on boot the following network devices (wifi0, ath0)
47
for iface in wifi0 ath0; do
47
for iface in wifi0 ath0; do
48
    for file in networking/profiles/default/ifcfg \
48
    for file in networking/profiles/default/ifcfg \
49
	networking/devices/ifcfg \
49
	networking/devices/ifcfg \
50
	network-scripts/ifcfg; do
50
	network-scripts/ifcfg; do
51
      if [ -e /etc/sysconfig/${file}-${iface} ]; then
51
      if [ -e /etc/sysconfig/${file}-${iface} ]; then
52
	  sed -i "s/ONBOOT=.*/ONBOOT=no/" /etc/sysconfig/${file}-${iface}
52
	  sed -i "s/ONBOOT=.*/ONBOOT=no/" /etc/sysconfig/${file}-${iface}
53
      fi
53
      fi
54
    done
54
    done
55
done
55
done
56
 
56
 
57
 
57
 
58
### disable start network devices, if NONET is defined
58
### disable start network devices, if NONET is defined
59
if [ $NONET ]; then
59
if [ $NONET ]; then
60
    # find all network devices (exclude loopback device)
60
    # find all network devices (exclude loopback device)
61
    config_files=$( find /etc/sysconfig -name ifcfg-* 2>/dev/null | grep -v ifcfg-lo )
61
    config_files=$( find /etc/sysconfig -name ifcfg-* 2>/dev/null | grep -v ifcfg-lo )
62
    for file in $config_files; do
62
    for file in $config_files; do
63
	sed -i "s/ONBOOT=.*/ONBOOT=no/" $file
63
	sed -i "s/ONBOOT=.*/ONBOOT=no/" $file
64
    done
64
    done
65
fi
65
fi
66
 
66
 
67
 
67
 
68
### define static IP and gateway, netmask
68
### define static IP and gateway, netmask
69
if [ $IPADDR ]; then    
69
if [ $IPADDR ]; then    
70
    if [ ! $GATEWAY ]; then
70
    if [ ! $GATEWAY ]; then
71
	# default gatway x.y.z.1
71
	# default gatway x.y.z.1
72
	GATEWAY=$( echo $IPADDR | awk -F"." '{ print $1"."$2"."$3".1" }' )
72
	GATEWAY=$( echo $IPADDR | awk -F"." '{ print $1"."$2"."$3".1" }' )
73
	if [ ! $NETMASK ]; then
73
	if [ ! $NETMASK ]; then
74
	    NETMASK=255.255.255.0
74
	    NETMASK=255.255.255.0
75
	fi
75
	fi
76
    fi
76
    fi
77
    # create config files for eth0
77
    # create config files for eth0
78
    for iface in eth0; do
78
    for iface in eth0; do
79
	for file in networking/profiles/default/ifcfg \
79
	for file in networking/profiles/default/ifcfg \
80
	            networking/devices/ifcfg \
80
	            networking/devices/ifcfg \
81
	            network-scripts/ifcfg; do
81
	            network-scripts/ifcfg; do
82
	  sed -i "s/BOOTPROTO=.*/BOOTPROTO=none/" /etc/sysconfig/${file}-${iface}
82
	  sed -i "s/BOOTPROTO=.*/BOOTPROTO=none/" /etc/sysconfig/${file}-${iface}
83
	  echo "IPADDR=$IPADDR" > /etc/sysconfig/${file}-${iface}
83
	  echo "IPADDR=$IPADDR" > /etc/sysconfig/${file}-${iface}
84
	  echo "NETMASK=$NETMASK" > /etc/sysconfig/${file}-${iface}
84
	  echo "NETMASK=$NETMASK" > /etc/sysconfig/${file}-${iface}
85
	  echo "GATEWAY=$GATEWAY" > /etc/sysconfig/${file}-${iface}
85
	  echo "GATEWAY=$GATEWAY" > /etc/sysconfig/${file}-${iface}
86
	done
86
	done
87
    done
87
    done
88
fi
88
fi
89
 
89
 
90
 
90
 
91
### activate ipw3945d daemon, if we have Intel IPW3945 WLAN 
91
### activate ipw3945d daemon, if we have Intel IPW3945 WLAN 
92
lspci | grep -q Intel.*3945ABG
92
lspci | grep -q Intel.*3945ABG
93
[ "$?" = "0" ] && chkconfig ipw3945d on 2>/dev/null
93
[ "$?" = "0" ] && chkconfig ipw3945d on 2>/dev/null
94
 
94
 
95
 
95
 
96
### activate Atheros WLAN
96
### activate Atheros WLAN
97
lspci | grep -q Ethernet.*Atheros
97
lspci | grep -q Ethernet.*Atheros
98
if [ "$?" = "0" ]; then
98
if [ "$?" = "0" ]; then
99
    # bring ath0 up
99
    # bring ath0 up
100
    ifconfig ath0 up > /dev/null 2>&1
100
    ifconfig ath0 up > /dev/null 2>&1
101
    # replace wifi with ath0
101
    # replace wifi with ath0
102
    for file in networking/profiles/default/ifcfg \
102
    for file in networking/profiles/default/ifcfg \
103
	networking/devices/ifcfg \
103
	networking/devices/ifcfg \
104
	network-scripts/ifcfg; do
104
	network-scripts/ifcfg; do
105
      if [ -e /etc/sysconfig/${file}-wifi0 ]; then
105
      if [ -e /etc/sysconfig/${file}-wifi0 ]; then
106
	  mv /etc/sysconfig/${file}-wifi0 /etc/sysconfig/${file}-ath0
106
	  mv /etc/sysconfig/${file}-wifi0 /etc/sysconfig/${file}-ath0
107
	  sed -i "s/wifi0/ath0/" /etc/sysconfig/${file}-ath0
107
	  sed -i "s/wifi0/ath0/" /etc/sysconfig/${file}-ath0
108
	  grep -q Wireless /etc/sysconfig/${file}-ath0
108
	  grep -q Wireless /etc/sysconfig/${file}-ath0
109
	  [ "$?" != "0" ] && echo "TYPE=Wireless" >> /etc/sysconfig/${file}-ath0
109
	  [ "$?" != "0" ] && echo "TYPE=Wireless" >> /etc/sysconfig/${file}-ath0
110
      fi
110
      fi
111
    done
111
    done
112
fi
-
 
113
112
fi
-
 
113
 
-
 
114
 
-
 
115
### enable 915resolution on Intel Mobile Display controller
-
 
116
lspci | grep -q Display.*Intel.*Mobile
-
 
117
[ "$?" = "0" ] && chkconfig 915resolution on
-
 
118
 
-
 
119