Subversion Repositories livecd

Rev

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

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