Subversion Repositories livecd

Rev

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

Rev 1 Rev 72
1
#!/bin/bash
1
#!/bin/bash
2
#
2
#
3
# Fix things during bootup - run first 
3
# Fix things during bootup - run first 
4
# Executed at the very end of /etc/rc.d/rc.sysinit
4
# Executed at the very end of /etc/rc.d/rc.sysinit
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
# start afs?
25
# start afs?
26
AFS=$( cmdline_parameter afs )
26
AFS=$( cmdline_parameter afs )
27
CELL=$( cmdline_value cell )
27
CELL=$( cmdline_value cell )
28
 
28
 
29
# or force no afs
29
# or force no afs
30
[ $( cmdline_parameter noafs ) ] && AFS=""
30
[ $( cmdline_parameter noafs ) ] && AFS=""
31
 
31
 
32
# start ssh server?
32
# start ssh server?
33
SSH=$( cmdline_parameter ssh )
33
SSH=$( cmdline_parameter ssh )
34
 
34
 
35
# root on NFS?
35
# root on NFS?
36
NFSROOT=$( cmdline_value nfsroot )
36
NFSROOT=$( cmdline_value nfsroot )
37
 
37
 
38
# PSI setup?
38
# PSI setup?
39
PSI=$( cmdline_parameter psi )
39
PSI=$( cmdline_parameter psi )
40
 
40
 
41
# do not start network
41
# do not start network
42
NONET=$( cmdline_parameter nonet )
42
NONET=$( cmdline_parameter nonet )
43
 
43
 
44
# Are PXE/TFTP and NFS Server the same host ? not uesed any more
44
# Are PXE/TFTP and NFS Server the same host ? not uesed any more
45
ONEMASTER=$( cmdline_parameter onemaster )
45
ONEMASTER=$( cmdline_parameter onemaster )
46
 
46
 
47
# static IP
47
# static IP
48
IPADDR=$( cmdline_value ip )
48
IPADDR=$( cmdline_value ip )
49
 
49
 
50
# gateway
50
# gateway
51
GATEWAY=$( cmdline_value gw )
51
GATEWAY=$( cmdline_value gw )
52
 
52
 
53
# netmask
53
# netmask
54
NETMASK=$( cmdline_value netmask )
54
NETMASK=$( cmdline_value netmask )
55
 
55
 
56
# fast booting ?
56
# fast booting ?
57
FASTBOOT=$( cmdline_parameter fastboot )
57
FASTBOOT=$( cmdline_parameter fastboot )
58
 
58
 
59
# if run=rdesktop, we do fast boot
59
# if run=rdesktop, we do fast boot
60
if [ "$( cmdline_value run )" = "rdesktop" ]; then
60
if [ "$( cmdline_value run )" = "rdesktop" ]; then
61
    FASTBOOT="fastboot"
61
    FASTBOOT="fastboot"
62
fi
62
fi
63
 
63
 
64
# start ntpd ?
64
# start ntpd ?
65
NTPD=$( cmdline_parameter ntpd )
65
NTPD=$( cmdline_parameter ntpd )
66
 
66
 
67
# services on/off
67
# services on/off
68
SERVICEON=$( cmdline_value serviceon )
68
SERVICEON=$( cmdline_value serviceon )
69
SERVICEOFF=$( cmdline_value serviceoff )
69
SERVICEOFF=$( cmdline_value serviceoff )
70
 
70
 
71
 
71
 
72
### -----------------------------------------------------------
72
### -----------------------------------------------------------
73
### Main
73
### Main
74
### -----------------------------------------------------------
74
### -----------------------------------------------------------
75
 
75
 
76
### disable rpcidmapd, if LiveCD mounted over NFS
76
### disable rpcidmapd, if LiveCD mounted over NFS
77
if [ $NFSROOT ]; then
77
if [ $NFSROOT ]; then
78
    chkconfig rpcidmapd off
78
    chkconfig rpcidmapd off
79
fi
79
fi
80
 
80
 
81
### restore blacklist (modified in runveryfirst)
81
### restore blacklist (modified in runveryfirst)
82
if [ $NFSROOT ]; then
82
if [ $NFSROOT ]; then
83
    [ -e /etc/hotplug/blacklist ] && BLACKLIST_FILE=/etc/hotplug/blacklist
83
    [ -e /etc/hotplug/blacklist ] && BLACKLIST_FILE=/etc/hotplug/blacklist
84
    [ -e /etc/modprobe.d/blacklist ] && BLACKLIST_FILE=/etc/modprobe.d/blacklist
84
    [ -e /etc/modprobe.d/blacklist ] && BLACKLIST_FILE=/etc/modprobe.d/blacklist
85
    mv -f ${BLACKLIST_FILE}.backup ${BLACKLIST_FILE}
85
    mv -f ${BLACKLIST_FILE}.backup ${BLACKLIST_FILE}
86
fi
86
fi
87
 
87
 
88
### get resolv.conf
88
### get resolv.conf
89
# if we have the LiveCD mounted over NFS
89
# if we have the LiveCD mounted over NFS
90
if [ $NFSROOT ]; then
90
if [ $NFSROOT ]; then
91
    cp -f /$MOUNTDIR/live/etc/resolv.conf /etc/
91
    cp -f /$MOUNTDIR/live/etc/resolv.conf /etc/
92
fi
92
fi
93
 
93
 
94
### disable shutdown of network and nfs, 
94
### disable shutdown of network and nfs, 
95
# if we have the LiveCD mounted over NFS
95
# if we have the LiveCD mounted over NFS
96
if [ $NFSROOT ]; then
96
if [ $NFSROOT ]; then
97
    if [ $ONEMASTER ]; then
97
    if [ $ONEMASTER ]; then
98
        # "network off" is only necessary, 
98
        # "network off" is only necessary, 
99
        # if PXE/TFTP and NTS server is on same machine
99
        # if PXE/TFTP and NTS server is on same machine
100
	chkconfig network off
100
	chkconfig network off
101
    fi
101
    fi
102
 
102
 
103
    rm -f /etc/rc.d/rc6.d/K75netfs
103
    rm -f /etc/rc.d/rc6.d/K75netfs
104
    rm -f /etc/rc.d/rc6.d/K86nfslock
104
    rm -f /etc/rc.d/rc6.d/K86nfslock
105
    rm -f /etc/rc.d/rc6.d/K87portmap
105
    rm -f /etc/rc.d/rc6.d/K87portmap
106
    rm -f /etc/rc.d/rc6.d/K90network
106
    rm -f /etc/rc.d/rc6.d/K90network
107
 
107
 
108
    rm -f /etc/rc.d/rc0.d/K75netfs
108
    rm -f /etc/rc.d/rc0.d/K75netfs
109
    rm -f /etc/rc.d/rc0.d/K86nfslock
109
    rm -f /etc/rc.d/rc0.d/K86nfslock
110
    rm -f /etc/rc.d/rc0.d/K87portmap
110
    rm -f /etc/rc.d/rc0.d/K87portmap
111
    rm -f /etc/rc.d/rc0.d/K90network
111
    rm -f /etc/rc.d/rc0.d/K90network
112
fi
112
fi
113
 
113
 
114
### create AFS mount point
114
### create AFS mount point
115
mkdir -p /afs
115
mkdir -p /afs
116
 
116
 
117
### enable AFS during start up, if given by boot parameter
117
### enable AFS during start up, if given by boot parameter
118
if [ $AFS ]; then
118
if [ $AFS ]; then
119
    chkconfig afs on
119
    chkconfig afs on
120
fi
120
fi
121
 
121
 
122
### disable some services for fast booting
122
### disable some services for fast booting
123
if [ $FASTBOOT ]; then    
123
if [ $FASTBOOT ]; then    
124
    echo "Fast booting enabled"
124
    echo "Fast booting enabled"
125
    chkconfig vpnclient_init off
125
    chkconfig vpnclient_init off
126
    chkconfig haldaemon off
126
    chkconfig haldaemon off
127
    chkconfig pcmcia off
127
    chkconfig pcmcia off
128
    chkconfig ntpd off
128
    chkconfig ntpd off
129
    chkconfig atd off
129
    chkconfig atd off
130
    chkconfig cpuspeed off
130
    chkconfig cpuspeed off
131
    chkconfig gpm off
131
    chkconfig gpm off
132
    chkconfig messagebus off
132
    chkconfig messagebus off
133
    rm -rf /etc/rc.d/rc3.d/S04kudzu-auto
133
    rm -rf /etc/rc.d/rc3.d/S04kudzu-auto
134
    rm -rf /etc/rc.d/rc5.d/S04kudzu-auto
134
    rm -rf /etc/rc.d/rc5.d/S04kudzu-auto
135
fi
135
fi
136
 
136
 
137
### enable ntpd?
137
### enable ntpd?
138
if [ $NTPD ]; then
138
if [ $NTPD ]; then
139
    chkconfig ntpd on
139
    chkconfig ntpd on
140
fi
140
fi
141
 
141
 
142
### enable SSH server during start up, if given by boot parameter
142
### enable SSH server during start up, if given by boot parameter
143
if [ $SSH ]; then
143
if [ $SSH ]; then
144
    chkconfig sshd on
144
    chkconfig sshd on
145
fi
145
fi
146
 
146
 
147
### services on
147
### services on
148
if [ -n $SERVICEON ]; then
148
if [ -n $SERVICEON ]; then
149
    for service in `echo "$SERVICEON" | tr ':' ' '`; do
149
    for service in `echo "$SERVICEON" | tr ':' ' '`; do
150
	if [ -f /etc/init.d/$service ]; then
150
	if [ -f /etc/init.d/$service ]; then
151
	    chkconfig $service on
151
	    chkconfig $service on
152
	fi
152
	fi
153
    done
153
    done
154
fi
154
fi
155
 
155
 
156
### services off
156
### services off
157
if [ -n $SERVICEOFF ]; then
157
if [ -n $SERVICEOFF ]; then
158
    for service in `echo "$SERVICEOFF" | tr ':' ' '`; do
158
    for service in `echo "$SERVICEOFF" | tr ':' ' '`; do
159
	if [ -f /etc/init.d/$service ]; then
159
	if [ -f /etc/init.d/$service ]; then
160
	    chkconfig $service off
160
	    chkconfig $service off
161
	fi
161
	fi
162
    done
162
    done
163
fi
163
fi
164
 
164
 
165
### fix perm of /tmp
165
### fix perm of /tmp
166
chmod 1777 /tmp
166
chmod 1777 /tmp
167
 
167
 
168
### link /opt -> /usr/opt !
168
### link /opt -> /usr/opt !
169
ln -s /usr/opt /opt
169
ln -s /usr/opt /opt
170
 
170
 
171
### create home
171
### create home
172
mkdir -p /home
172
mkdir -p /home
173
 
173
 
174
### create /scratch
174
### create /scratch
175
mkdir -p /scratch
175
mkdir -p /scratch
176
chmod 1777 /scratch
176
chmod 1777 /scratch
177
 
177
 
178
### create /data
178
### create /data
179
if [ $PSI ]; then
179
if [ $PSI ]; then
180
    mkdir -p /data
180
    mkdir -p /data
181
    chmod 1777 /data
181
    chmod 1777 /data
182
fi
182
fi
183
 
183
 
184
### add PSI master
184
### add PSI master
185
if [ $PSI ]; then
185
if [ $PSI ]; then
186
    mkdir -p /mnt/master
186
    mkdir -p /mnt/master
187
    echo "pxeserv01:/master       /mnt/master             nfs     nfsvers=2,noauto,nolock,ro 0 0" >> /etc/fstab
187
    echo "pxeserv01:/master       /mnt/master             nfs     nfsvers=2,noauto,nolock,ro 0 0" >> /etc/fstab
188
fi
188
fi
189
 
189
 
190
### set afs cell, if given by boot parameter
190
### set afs cell, if given by boot parameter
191
if [ $CELL ]; then
191
if [ $CELL ]; then
192
    echo $CELL > /usr/vice/etc/ThisCell
192
    echo $CELL > /usr/vice/etc/ThisCell
193
fi
193
fi
194
 
194
 
195
### do not activate network during bootup, if "nonet"
195
### do not activate network during bootup, if "nonet"
196
if [ $NONET ]; then
196
if [ $NONET ]; then
197
    for iface in eth0 eth1 eth2 eth3; do
197
    for iface in eth0 eth1 eth2 eth3; do
198
	for file in networking/profiles/default/ifcfg \
198
	for file in networking/profiles/default/ifcfg \
199
	            networking/devices/ifcfg \
199
	            networking/devices/ifcfg \
200
                    network-scripts/ifcfg; do
200
                    network-scripts/ifcfg; do
201
	  if [ -e /etc/sysconfig/${file}-${iface} ]; then
201
	  if [ -e /etc/sysconfig/${file}-${iface} ]; then
202
	      sed -i "s/ONBOOT=.*/ONBOOT=no/" /etc/sysconfig/${file}-${iface}
202
	      sed -i "s/ONBOOT=.*/ONBOOT=no/" /etc/sysconfig/${file}-${iface}
203
	  fi
203
	  fi
204
	done
204
	done
205
    done
205
    done
206
fi
206
fi
207
 
207
 
208
### define static IP and gateway, netmask
208
### define static IP and gateway, netmask
209
if [ $IPADDR ]; then    
209
if [ $IPADDR ]; then    
210
    if [ ! $GATEWAY ]; then
210
    if [ ! $GATEWAY ]; then
211
	# default gatway x.y.z.1
211
	# default gatway x.y.z.1
212
	GATEWAY=$( echo $IPADDR | awk -F"." '{ print $1"."$2"."$3".1" }' )
212
	GATEWAY=$( echo $IPADDR | awk -F"." '{ print $1"."$2"."$3".1" }' )
213
	if [ ! $NETMASK ]; then
213
	if [ ! $NETMASK ]; then
214
	    NETMASK=255.255.255.0
214
	    NETMASK=255.255.255.0
215
	fi
215
	fi
216
    fi
216
    fi
217
    # create config files for eth0
217
    # create config files for eth0
218
    for iface in eth0; do
218
    for iface in eth0; do
219
	for file in networking/profiles/default/ifcfg \
219
	for file in networking/profiles/default/ifcfg \
220
	            networking/devices/ifcfg \
220
	            networking/devices/ifcfg \
221
	            network-scripts/ifcfg; do
221
	            network-scripts/ifcfg; do
222
	  sed -i "s/BOOTPROTO=.*/BOOTPROTO=none/" /etc/sysconfig/${file}-${iface}
222
	  sed -i "s/BOOTPROTO=.*/BOOTPROTO=none/" /etc/sysconfig/${file}-${iface}
223
	  echo "IPADDR=$IPADDR" > /etc/sysconfig/${file}-${iface}
223
	  echo "IPADDR=$IPADDR" > /etc/sysconfig/${file}-${iface}
224
	  echo "NETMASK=$NETMASK" > /etc/sysconfig/${file}-${iface}
224
	  echo "NETMASK=$NETMASK" > /etc/sysconfig/${file}-${iface}
225
	  echo "GATEWAY=$GATEWAY" > /etc/sysconfig/${file}-${iface}
225
	  echo "GATEWAY=$GATEWAY" > /etc/sysconfig/${file}-${iface}
226
	done
226
	done
227
    done
227
    done
228
fi
228
fi
-
 
229
 
-
 
230
### activate ipw3945d deamon, if we have Intel IPW3945 WLAN 
-
 
231
lspci | grep -q Intel.*3945ABG
-
 
232
[ "$?" = "0" ] && chkconfig ipw3945d on 2>/dev/null
-
 
233