| 1 |
beyerle@PS |
1 |
#!/bin/bash
|
|
|
2 |
#
|
|
|
3 |
# Fix things during bootup - run first
|
|
|
4 |
# Executed at the very end of /etc/rc.d/rc.sysinit
|
|
|
5 |
#
|
|
|
6 |
# Urs Beyerle, PSI
|
|
|
7 |
#
|
|
|
8 |
|
|
|
9 |
### -----------------------------------------------------------
|
|
|
10 |
### definitions
|
|
|
11 |
### -----------------------------------------------------------
|
|
|
12 |
|
|
|
13 |
# dir of mounted /$MOUNTDIR/live
|
|
|
14 |
MOUNTDIR=livecd
|
|
|
15 |
|
|
|
16 |
# source functions
|
|
|
17 |
. /$MOUNTDIR/live/liblinuxlive
|
|
|
18 |
. /etc/init.d/functions
|
|
|
19 |
|
|
|
20 |
|
|
|
21 |
### -----------------------------------------------------------
|
|
|
22 |
### Get boot parameters
|
|
|
23 |
### -----------------------------------------------------------
|
|
|
24 |
|
|
|
25 |
# start afs?
|
|
|
26 |
AFS=$( cmdline_parameter afs )
|
|
|
27 |
CELL=$( cmdline_value cell )
|
|
|
28 |
|
|
|
29 |
# or force no afs
|
|
|
30 |
[ $( cmdline_parameter noafs ) ] && AFS=""
|
|
|
31 |
|
|
|
32 |
# start ssh server?
|
|
|
33 |
SSH=$( cmdline_parameter ssh )
|
|
|
34 |
|
|
|
35 |
# root on NFS?
|
|
|
36 |
NFSROOT=$( cmdline_value nfsroot )
|
|
|
37 |
|
|
|
38 |
# PSI setup?
|
|
|
39 |
PSI=$( cmdline_parameter psi )
|
|
|
40 |
|
|
|
41 |
# do not start network
|
|
|
42 |
NONET=$( cmdline_parameter nonet )
|
|
|
43 |
|
|
|
44 |
# Are PXE/TFTP and NFS Server the same host ? not uesed any more
|
|
|
45 |
ONEMASTER=$( cmdline_parameter onemaster )
|
|
|
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 ?
|
|
|
57 |
FASTBOOT=$( cmdline_parameter fastboot )
|
|
|
58 |
|
|
|
59 |
# if run=rdesktop, we do fast boot
|
|
|
60 |
if [ "$( cmdline_value run )" = "rdesktop" ]; then
|
|
|
61 |
FASTBOOT="fastboot"
|
|
|
62 |
fi
|
|
|
63 |
|
|
|
64 |
# start ntpd ?
|
|
|
65 |
NTPD=$( cmdline_parameter ntpd )
|
|
|
66 |
|
|
|
67 |
# services on/off
|
|
|
68 |
SERVICEON=$( cmdline_value serviceon )
|
|
|
69 |
SERVICEOFF=$( cmdline_value serviceoff )
|
|
|
70 |
|
|
|
71 |
|
|
|
72 |
### -----------------------------------------------------------
|
|
|
73 |
### Main
|
|
|
74 |
### -----------------------------------------------------------
|
|
|
75 |
|
|
|
76 |
### disable rpcidmapd, if LiveCD mounted over NFS
|
|
|
77 |
if [ $NFSROOT ]; then
|
|
|
78 |
chkconfig rpcidmapd off
|
|
|
79 |
fi
|
|
|
80 |
|
|
|
81 |
### restore blacklist (modified in runveryfirst)
|
|
|
82 |
if [ $NFSROOT ]; then
|
|
|
83 |
[ -e /etc/hotplug/blacklist ] && BLACKLIST_FILE=/etc/hotplug/blacklist
|
|
|
84 |
[ -e /etc/modprobe.d/blacklist ] && BLACKLIST_FILE=/etc/modprobe.d/blacklist
|
|
|
85 |
mv -f ${BLACKLIST_FILE}.backup ${BLACKLIST_FILE}
|
|
|
86 |
fi
|
|
|
87 |
|
|
|
88 |
### get resolv.conf
|
|
|
89 |
# if we have the LiveCD mounted over NFS
|
|
|
90 |
if [ $NFSROOT ]; then
|
|
|
91 |
cp -f /$MOUNTDIR/live/etc/resolv.conf /etc/
|
|
|
92 |
fi
|
|
|
93 |
|
|
|
94 |
### disable shutdown of network and nfs,
|
|
|
95 |
# if we have the LiveCD mounted over NFS
|
|
|
96 |
if [ $NFSROOT ]; then
|
|
|
97 |
if [ $ONEMASTER ]; then
|
|
|
98 |
# "network off" is only necessary,
|
|
|
99 |
# if PXE/TFTP and NTS server is on same machine
|
|
|
100 |
chkconfig network off
|
|
|
101 |
fi
|
|
|
102 |
|
|
|
103 |
rm -f /etc/rc.d/rc6.d/K75netfs
|
|
|
104 |
rm -f /etc/rc.d/rc6.d/K86nfslock
|
|
|
105 |
rm -f /etc/rc.d/rc6.d/K87portmap
|
|
|
106 |
rm -f /etc/rc.d/rc6.d/K90network
|
|
|
107 |
|
|
|
108 |
rm -f /etc/rc.d/rc0.d/K75netfs
|
|
|
109 |
rm -f /etc/rc.d/rc0.d/K86nfslock
|
|
|
110 |
rm -f /etc/rc.d/rc0.d/K87portmap
|
|
|
111 |
rm -f /etc/rc.d/rc0.d/K90network
|
|
|
112 |
fi
|
|
|
113 |
|
|
|
114 |
### create AFS mount point
|
|
|
115 |
mkdir -p /afs
|
|
|
116 |
|
|
|
117 |
### enable AFS during start up, if given by boot parameter
|
|
|
118 |
if [ $AFS ]; then
|
|
|
119 |
chkconfig afs on
|
|
|
120 |
fi
|
|
|
121 |
|
|
|
122 |
### disable some services for fast booting
|
|
|
123 |
if [ $FASTBOOT ]; then
|
|
|
124 |
echo "Fast booting enabled"
|
|
|
125 |
chkconfig vpnclient_init off
|
|
|
126 |
chkconfig haldaemon off
|
|
|
127 |
chkconfig pcmcia off
|
|
|
128 |
chkconfig ntpd off
|
|
|
129 |
chkconfig atd off
|
|
|
130 |
chkconfig cpuspeed off
|
|
|
131 |
chkconfig gpm off
|
|
|
132 |
chkconfig messagebus off
|
|
|
133 |
rm -rf /etc/rc.d/rc3.d/S04kudzu-auto
|
|
|
134 |
rm -rf /etc/rc.d/rc5.d/S04kudzu-auto
|
|
|
135 |
fi
|
|
|
136 |
|
|
|
137 |
### enable ntpd?
|
|
|
138 |
if [ $NTPD ]; then
|
|
|
139 |
chkconfig ntpd on
|
|
|
140 |
fi
|
|
|
141 |
|
|
|
142 |
### enable SSH server during start up, if given by boot parameter
|
|
|
143 |
if [ $SSH ]; then
|
|
|
144 |
chkconfig sshd on
|
|
|
145 |
fi
|
|
|
146 |
|
|
|
147 |
### services on
|
|
|
148 |
if [ -n $SERVICEON ]; then
|
|
|
149 |
for service in `echo "$SERVICEON" | tr ':' ' '`; do
|
|
|
150 |
if [ -f /etc/init.d/$service ]; then
|
|
|
151 |
chkconfig $service on
|
|
|
152 |
fi
|
|
|
153 |
done
|
|
|
154 |
fi
|
|
|
155 |
|
|
|
156 |
### services off
|
|
|
157 |
if [ -n $SERVICEOFF ]; then
|
|
|
158 |
for service in `echo "$SERVICEOFF" | tr ':' ' '`; do
|
|
|
159 |
if [ -f /etc/init.d/$service ]; then
|
|
|
160 |
chkconfig $service off
|
|
|
161 |
fi
|
|
|
162 |
done
|
|
|
163 |
fi
|
|
|
164 |
|
|
|
165 |
### fix perm of /tmp
|
|
|
166 |
chmod 1777 /tmp
|
|
|
167 |
|
|
|
168 |
### link /opt -> /usr/opt !
|
|
|
169 |
ln -s /usr/opt /opt
|
|
|
170 |
|
|
|
171 |
### create home
|
|
|
172 |
mkdir -p /home
|
|
|
173 |
|
|
|
174 |
### create /scratch
|
|
|
175 |
mkdir -p /scratch
|
|
|
176 |
chmod 1777 /scratch
|
|
|
177 |
|
|
|
178 |
### create /data
|
|
|
179 |
if [ $PSI ]; then
|
|
|
180 |
mkdir -p /data
|
|
|
181 |
chmod 1777 /data
|
|
|
182 |
fi
|
|
|
183 |
|
|
|
184 |
### add PSI master
|
|
|
185 |
if [ $PSI ]; then
|
|
|
186 |
mkdir -p /mnt/master
|
|
|
187 |
echo "pxeserv01:/master /mnt/master nfs nfsvers=2,noauto,nolock,ro 0 0" >> /etc/fstab
|
|
|
188 |
fi
|
|
|
189 |
|
|
|
190 |
### set afs cell, if given by boot parameter
|
|
|
191 |
if [ $CELL ]; then
|
|
|
192 |
echo $CELL > /usr/vice/etc/ThisCell
|
|
|
193 |
fi
|
|
|
194 |
|
|
|
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
|