Subversion Repositories livecd

Rev

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

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