1 |
beyerle@PS |
1 |
#!/bin/bash
|
|
|
2 |
#
|
|
|
3 |
###############################################################
|
|
|
4 |
#
|
|
|
5 |
# LiveCD customization script
|
|
|
6 |
#
|
14 |
beyerle@PS |
7 |
# Run this script on a SL Installation
|
1 |
beyerle@PS |
8 |
# to prepare the system for a LiveCD
|
|
|
9 |
#
|
|
|
10 |
# Urs Beyerle, PSI
|
|
|
11 |
#
|
|
|
12 |
###############################################################
|
|
|
13 |
|
23 |
beyerle@PS |
14 |
### source livecd.conf
|
1 |
beyerle@PS |
15 |
. livecd.conf
|
|
|
16 |
|
|
|
17 |
###############################################################
|
|
|
18 |
|
|
|
19 |
function usage() {
|
|
|
20 |
|
|
|
21 |
## Usage
|
|
|
22 |
# ----------------------------------------------------------
|
|
|
23 |
|
|
|
24 |
cat <<EOF
|
|
|
25 |
|
|
|
26 |
Optional Options:
|
|
|
27 |
|
|
|
28 |
-h: print this screen
|
|
|
29 |
-psi: customize for PSI Live CD
|
|
|
30 |
-dvd: customize for Live DVD
|
|
|
31 |
-mini: customize for Mini Live CD
|
|
|
32 |
|
|
|
33 |
EOF
|
|
|
34 |
|
|
|
35 |
}
|
|
|
36 |
|
|
|
37 |
###############################################################
|
|
|
38 |
|
|
|
39 |
###############################################################
|
|
|
40 |
# Definitions
|
|
|
41 |
###############################################################
|
|
|
42 |
|
|
|
43 |
### read options from command-line
|
|
|
44 |
PSI=""
|
|
|
45 |
while [ $# -gt 0 ]; do
|
|
|
46 |
|
|
|
47 |
case "$1" in
|
|
|
48 |
-h)
|
|
|
49 |
usage; exit;;
|
|
|
50 |
-psi)
|
|
|
51 |
PSI=-psi; shift; continue;;
|
|
|
52 |
-dvd)
|
|
|
53 |
DVD=-dvd; shift; continue;;
|
|
|
54 |
-mini)
|
|
|
55 |
MINI=-mini; shift; continue;;
|
|
|
56 |
*)
|
|
|
57 |
usage; exit;;
|
|
|
58 |
esac
|
|
|
59 |
|
|
|
60 |
done
|
|
|
61 |
|
|
|
62 |
### arch x86_64 or i686 ?
|
|
|
63 |
ARCH=$( /bin/arch )
|
|
|
64 |
[ "$ARCH" != "x86_64" ] && ARCH=i686
|
|
|
65 |
|
23 |
beyerle@PS |
66 |
### set local username for PSI
|
|
|
67 |
[ $PSI ] && LOCALUSER=l_psi
|
1 |
beyerle@PS |
68 |
|
|
|
69 |
|
23 |
beyerle@PS |
70 |
|
1 |
beyerle@PS |
71 |
###############################################################
|
|
|
72 |
# Backup some original files
|
|
|
73 |
###############################################################
|
|
|
74 |
|
|
|
75 |
echo "Backup original files ..."
|
|
|
76 |
|
|
|
77 |
ori_files="/etc/init.d/netfs \
|
|
|
78 |
/etc/init.d/autofs \
|
|
|
79 |
/etc/init.d/halt \
|
|
|
80 |
/etc/init.d/network
|
|
|
81 |
/etc/init.d/functions \
|
|
|
82 |
/etc/rc.d/rc.sysinit \
|
|
|
83 |
/etc/sysconfig/afs \
|
|
|
84 |
/etc/motd \
|
|
|
85 |
/etc/redhat-release \
|
16 |
beyerle@PS |
86 |
/etc/rc.d/rc.local \
|
1 |
beyerle@PS |
87 |
/etc/resolv.conf"
|
|
|
88 |
|
|
|
89 |
for file in $ori_files; do
|
|
|
90 |
[ ! -e ${file}.ori ] && cp -a ${file} ${file}.ori 2>/dev/null
|
|
|
91 |
done
|
|
|
92 |
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
###############################################################
|
|
|
96 |
# Configure system
|
|
|
97 |
###############################################################
|
|
|
98 |
|
|
|
99 |
echo "Configure system ..."
|
|
|
100 |
|
112 |
beyerle@PS |
101 |
# build nvidia kernel modules
|
23 |
beyerle@PS |
102 |
[ -x /usr/sbin/mknvidia ] && mknvidia
|
1 |
beyerle@PS |
103 |
|
|
|
104 |
# build vpnclient kernel module
|
23 |
beyerle@PS |
105 |
[ -x /usr/sbin/mkvpnclient ] && mkvpnclient
|
1 |
beyerle@PS |
106 |
|
|
|
107 |
# Update Virus definitions
|
|
|
108 |
# run freshclam
|
|
|
109 |
if [ -x /usr/bin/freshclam ]; then
|
|
|
110 |
echo; echo "Run /usr/bin/freshclam:"
|
|
|
111 |
/etc/init.d/clamd status || /etc/init.d/clamd start && /usr/bin/freshclam
|
|
|
112 |
/etc/init.d/clamd stop
|
|
|
113 |
echo
|
|
|
114 |
fi
|
|
|
115 |
# update f-prot and uvscan
|
|
|
116 |
[ -x /usr/local/f-prot/tools/check-updates.pl ] && /usr/local/f-prot/tools/check-updates.pl
|
|
|
117 |
[ -x /usr/local/uvscan/update-dat ] && /usr/local/uvscan/update-dat
|
|
|
118 |
|
|
|
119 |
# run depmod -a for the LiveCD kernels
|
|
|
120 |
echo "Run depmod -a $KERNEL ..."; depmod -a $KERNEL
|
|
|
121 |
if [ $SMP ]; then
|
|
|
122 |
echo "Run depmod -a ${KERNEL}smp ..."
|
|
|
123 |
depmod -a ${KERNEL}smp
|
|
|
124 |
fi
|
|
|
125 |
|
|
|
126 |
# delete users (just to be sure)
|
|
|
127 |
userdel -r $LOCALUSER 2>/dev/null
|
|
|
128 |
userdel -r l_psi 2>/dev/null
|
|
|
129 |
userdel -r sluser 2>/dev/null
|
|
|
130 |
userdel -r user 2>/dev/null
|
|
|
131 |
|
|
|
132 |
# umount PSI master
|
23 |
beyerle@PS |
133 |
[ $PSI ] && umount /mnt/master 2>/dev/null
|
1 |
beyerle@PS |
134 |
|
|
|
135 |
# copy back /etc/yum.repos.d
|
|
|
136 |
if [ ! $PSI ]; then
|
|
|
137 |
if [ -d /etc/yum.repos.d.ori ]; then
|
|
|
138 |
cp -a /etc/yum.repos.d.ori /etc/yum.repos.d
|
|
|
139 |
fi
|
|
|
140 |
fi
|
|
|
141 |
|
|
|
142 |
# run cfagent
|
|
|
143 |
if [ $PSI ]; then
|
110 |
beyerle@PS |
144 |
if [ -e /usr/bin/cfagent ]; then
|
|
|
145 |
# cfagent needs running afs
|
|
|
146 |
/etc/init.d/afs start
|
|
|
147 |
echo "Run cfagent ..."
|
|
|
148 |
cfagent
|
|
|
149 |
/etc/init.d/afs stop
|
|
|
150 |
fi
|
1 |
beyerle@PS |
151 |
fi
|
|
|
152 |
|
|
|
153 |
echo "done."
|
|
|
154 |
echo "--------------------------------------------"
|
|
|
155 |
|
|
|
156 |
|
|
|
157 |
|
|
|
158 |
###############################################################
|
|
|
159 |
# Clean up and delete files
|
|
|
160 |
###############################################################
|
|
|
161 |
|
|
|
162 |
echo "Cleaning up ..."
|
|
|
163 |
|
|
|
164 |
### set LANG
|
|
|
165 |
export LANG=C
|
|
|
166 |
|
|
|
167 |
### stop AFS
|
|
|
168 |
/etc/init.d/afs stop 2>/dev/null
|
|
|
169 |
|
|
|
170 |
### clean up yum
|
|
|
171 |
yum clean all >/dev/null
|
|
|
172 |
rm -rf /var/cache/yum/*
|
|
|
173 |
|
|
|
174 |
### remove cfengine log files
|
|
|
175 |
rm -f /var/cfengine/*log
|
|
|
176 |
|
|
|
177 |
### delete log files
|
|
|
178 |
find /var/log/ -type f -exec rm -f {} \;
|
|
|
179 |
|
|
|
180 |
### clean rpm database
|
|
|
181 |
rm -rf /var/lib/rpm/__db.*
|
|
|
182 |
|
|
|
183 |
### clean /var/spool/mail
|
|
|
184 |
rm -rf /var/spool/mail/*
|
|
|
185 |
touch /var/spool/mail/root
|
|
|
186 |
chmod 600 /var/spool/mail/root
|
|
|
187 |
|
|
|
188 |
### delete .cfsaved Files
|
|
|
189 |
if [ $PSI ]; then
|
|
|
190 |
echo -n "Delete .cfsaved Files, please wait: "
|
|
|
191 |
find / -xdev -name "*\.cfsaved" -exec rm -f {} \;
|
|
|
192 |
echo "ok."
|
|
|
193 |
fi
|
|
|
194 |
|
|
|
195 |
### delete .rpmori .rpm Files in /etc
|
|
|
196 |
find /etc -name "*\.rpmorig" -exec rm -f {} \;
|
|
|
197 |
find /etc -name "*\.rpmnew" -exec rm -f {} \;
|
29 |
beyerle@PS |
198 |
find /etc -name "*\.rpmsave" -exec rm -f {} \;
|
1 |
beyerle@PS |
199 |
|
|
|
200 |
### delete *~ files in /etc
|
|
|
201 |
find /etc | grep "~$" | while read f; do rm -f "$f"; done
|
|
|
202 |
|
|
|
203 |
### clean up /root
|
56 |
beyerle@PS |
204 |
rm -f /root/.bash_history
|
|
|
205 |
rm -f /root/.ssh/known_hosts
|
|
|
206 |
rm -rf /root/.subversion
|
1 |
beyerle@PS |
207 |
|
|
|
208 |
### clean AFS cache
|
|
|
209 |
if [ -d /usr/vice/cache ]; then
|
|
|
210 |
rm -rf /usr/vice/cache
|
|
|
211 |
mkdir /usr/vice/cache
|
|
|
212 |
fi
|
|
|
213 |
if [ -d /var/cache/openafs ]; then
|
|
|
214 |
rm -rf /var/cache/openafs
|
|
|
215 |
mkdir /var/cache/openafs
|
|
|
216 |
fi
|
|
|
217 |
|
|
|
218 |
### clean up /var/tmp
|
|
|
219 |
rm -rf /var/tmp/*
|
|
|
220 |
|
|
|
221 |
### remove root passwd
|
|
|
222 |
sed -i "s|^root:.*|root:\*:12943:0:99999:7:::|" /etc/shadow
|
|
|
223 |
sed -i "s|^root:.*:0:0|root:x:0:0|" /etc/passwd
|
|
|
224 |
|
|
|
225 |
### remove /.autofsck
|
23 |
beyerle@PS |
226 |
rm -f /.autofsck
|
1 |
beyerle@PS |
227 |
|
|
|
228 |
### disable cfagent
|
112 |
beyerle@PS |
229 |
[ $PSI ] && rm -f /etc/cron.d/cfengine
|
1 |
beyerle@PS |
230 |
|
|
|
231 |
### disable check_update in rc.local.psi
|
23 |
beyerle@PS |
232 |
[ $PSI ] && sed -i "s|/etc/init.d/check_update|# /etc/init.d/check_update|" /etc/rc.d/rc.local.psi
|
1 |
beyerle@PS |
233 |
|
|
|
234 |
### create in /boot link to LiveCD kernel(s)
|
|
|
235 |
ln -fs /boot/vmlinuz-$KERNEL /boot/vmlinuz
|
|
|
236 |
[ $SMP ] && ln -fs /boot/vmlinuz-${KERNEL}smp /boot/vmlinuz${SMP}
|
|
|
237 |
|
110 |
beyerle@PS |
238 |
### remove ssh keys
|
1 |
beyerle@PS |
239 |
FILES_REMOVE="/etc/ssh/ssh_host_key \
|
|
|
240 |
/etc/ssh/ssh_host_key.pub \
|
|
|
241 |
/etc/ssh/ssh_host_rsa_key.pub \
|
|
|
242 |
/etc/ssh/ssh_host_dsa_key \
|
|
|
243 |
/etc/ssh/ssh_host_dsa_key.pub"
|
|
|
244 |
for file in $FILES_REMOVE; do
|
23 |
beyerle@PS |
245 |
rm -f $file
|
1 |
beyerle@PS |
246 |
done
|
|
|
247 |
|
|
|
248 |
### remove useless cronjobs
|
|
|
249 |
mkdir -p /etc/cron_backup
|
|
|
250 |
mv /etc/cron.d/sysstat /etc/cron_backup/ 2>/dev/null
|
|
|
251 |
mv /etc/cron.daily/00-makewhatis.cron /etc/cron_backup/ 2>/dev/null
|
|
|
252 |
mv /etc/cron.weekly/00-makewhatis.cron /etc/cron_backup/00-makewhatis.cron.weekly 2>/dev/null
|
|
|
253 |
mv /etc/cron.daily/rpm /etc/cron_backup/ 2>/dev/null
|
|
|
254 |
mv /etc/cron.daily/slocate.cron /etc/cron_backup/ 2>/dev/null
|
|
|
255 |
mv /etc/cron.daily/tetex.cron /etc/cron_backup/ 2>/dev/null
|
|
|
256 |
mv /etc/cron.daily/yum.cron /etc/cron_backup/ 2>/dev/null
|
|
|
257 |
mv /etc/cron.daily/prelink /etc/cron_backup/ 2>/dev/null
|
|
|
258 |
mv /etc/cron.daily/00-logwatch /etc/cron_backup/ 2>/dev/null
|
|
|
259 |
|
|
|
260 |
### remove desktop entry from crossover
|
23 |
beyerle@PS |
261 |
[ $PSI ] && rm -f "/usr/share/apps/kdesktop/DesktopLinks/Internet Explorer.desktop"
|
1 |
beyerle@PS |
262 |
|
|
|
263 |
### remove backup of /etc/X11/xorg.conf
|
|
|
264 |
rm -f /etc/X11/xorg.conf.ori 2>/dev/null
|
|
|
265 |
rm -f /etc/X11/xorg.conf.backup 2>/dev/null
|
|
|
266 |
|
|
|
267 |
### remove unused dirs in /lib/modules
|
|
|
268 |
ls /lib/modules/ | grep -v $KERNEL | while read mod_dir; do
|
|
|
269 |
rpm -qf --quiet /lib/modules/$mod_dir
|
|
|
270 |
if [ $? != "0" ]; then
|
|
|
271 |
if [ $mod_dir != "" ]; then
|
|
|
272 |
cleaned_dir=/tmp/cleaned-$( date +%Y%m%d%H%M )
|
|
|
273 |
mkdir -p $cleaned_dir
|
|
|
274 |
echo "Move dir /lib/modules/$mod_dir to $cleaned_dir"
|
|
|
275 |
mv -f /lib/modules/$mod_dir $cleaned_dir/
|
|
|
276 |
fi
|
|
|
277 |
fi
|
|
|
278 |
done
|
|
|
279 |
|
|
|
280 |
### move some unneeded files to /mini (not for LiveDVD and miniCD)
|
110 |
beyerle@PS |
281 |
# to save disk space
|
|
|
282 |
|
1 |
beyerle@PS |
283 |
if [ ! $DVD ] && [ ! $MINI ]; then
|
|
|
284 |
|
|
|
285 |
mkdir -p /mini
|
|
|
286 |
|
80 |
beyerle@PS |
287 |
echo "Move some folders to /mini, to save disk space:"
|
|
|
288 |
|
1 |
beyerle@PS |
289 |
# move some dirs in /usr/share/doc to /mini
|
|
|
290 |
mkdir -p /mini/usr/share/doc
|
115 |
beyerle@PS |
291 |
mv -v /usr/share/doc/openafs-* /mini/usr/share/doc 2>/dev/null
|
|
|
292 |
mv -v /usr/share/doc/gcc-* /mini/usr/share/doc 2>/dev/null
|
|
|
293 |
mv -v /usr/share/doc/pine-* /mini/usr/share/doc 2>/dev/null
|
|
|
294 |
mv -v /usr/share/doc/ntp-* /mini/usr/share/doc 2>/dev/null
|
|
|
295 |
mv -v /usr/share/doc/cups-* /mini/usr/share/doc 2>/dev/null
|
|
|
296 |
mv -v /usr/share/doc/testdisk-* /mini/usr/share/doc 2>/dev/null
|
|
|
297 |
mv -v /usr/share/doc/htdig-* /mini/usr/share/doc 2>/dev/null
|
|
|
298 |
mv -v /usr/share/doc/gnome-vfs2-* /mini/usr/share/doc 2>/dev/null
|
|
|
299 |
mv -v /usr/share/doc/bash-* /mini/usr/share/doc 2>/dev/null
|
|
|
300 |
mv -v /usr/share/doc/exim-* /mini/usr/share/doc 2>/dev/null
|
80 |
beyerle@PS |
301 |
mv -v /usr/share/doc/ghostscript-* /mini/usr/share/doc 2>/dev/null
|
|
|
302 |
mv -v /usr/share/doc/gnuplot-* /mini/usr/share/doc 2>/dev/null
|
|
|
303 |
mv -v /usr/share/doc/ImageMagick-* /mini/usr/share/doc 2>/dev/null
|
|
|
304 |
mv -v /usr/share/doc/isdn4k-utils-* /mini/usr/share/doc 2>/dev/null
|
|
|
305 |
mv -v /usr/share/doc/sane-backends-* /mini/usr/share/doc 2>/dev/null
|
73 |
beyerle@PS |
306 |
|
1 |
beyerle@PS |
307 |
# move zipped java source to /mini, if j2sdk is installed
|
|
|
308 |
java_src=$( rpm -ql j2sdk 2>/dev/null | grep src.zip )
|
80 |
beyerle@PS |
309 |
[ -e "$java_src" ] && mv -v "$java_src" /mini/
|
|
|
310 |
|
1 |
beyerle@PS |
311 |
fi
|
|
|
312 |
|
|
|
313 |
echo "done."
|
|
|
314 |
echo "--------------------------------------------"
|
|
|
315 |
|
|
|
316 |
|
|
|
317 |
|
|
|
318 |
###############################################################
|
|
|
319 |
# Modify files
|
|
|
320 |
###############################################################
|
|
|
321 |
|
|
|
322 |
echo "Modify files ..."
|
|
|
323 |
|
|
|
324 |
### remove AFS startup warning about cache
|
23 |
beyerle@PS |
325 |
[ $PSI ] && sed -i "/\!\!\!/d" /etc/init.d/afs
|
1 |
beyerle@PS |
326 |
|
|
|
327 |
### disable umount of loop device during shutdown
|
|
|
328 |
# this is done really dirty at the moment:
|
|
|
329 |
# -> just replace "loop" with non existing device "lo_fake"
|
|
|
330 |
|
|
|
331 |
[ -e /etc/init.d/netfs ] && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/netfs
|
|
|
332 |
[ -e /etc/init.d/autofs ] && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/autofs
|
|
|
333 |
[ -e /etc/init.d/halt ] && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/halt
|
|
|
334 |
[ -e /etc/init.d/functions ] && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/functions
|
|
|
335 |
|
|
|
336 |
# do not shuttdown loopback interface
|
|
|
337 |
sed -i "s|[^#]action \$\"Shutting down loopback interface:|\t#action \$\"Shutting down loopback interface:|" /etc/init.d/network
|
|
|
338 |
|
|
|
339 |
### copy new /etc/init.d/halt
|
|
|
340 |
cp -a customize/sl${OS_RELEASE}/halt /etc/init.d/halt
|
|
|
341 |
|
|
|
342 |
### in /etc/rc.d/rc.sysinit
|
|
|
343 |
# comment out 'initlog -c "fsck -T -a $rootdev $fsckoptions"'
|
|
|
344 |
# to disable fsck of root filesystem
|
|
|
345 |
sed -i "s|\tfsck -T -a \$rootdev|\tsleep 0; #fsck -T -a \$rootdev|" /etc/rc.d/rc.sysinit
|
|
|
346 |
sed -i "s|\tinitlog -c \"fsck -T -a \$rootdev|\tsleep 0; #initlog -c \"fsck -T -a \$rootdev|" /etc/rc.d/rc.sysinit
|
|
|
347 |
# disable "Remounting root filesystem in read-write mode"
|
|
|
348 |
sed -i "s| action \$\"Remounting root filesystem|#action \$\"Remounting root filesystem|" /etc/rc.d/rc.sysinit
|
|
|
349 |
|
|
|
350 |
### start afs with option -memcache !
|
|
|
351 |
if [ -e /etc/sysconfig/afs ]; then
|
|
|
352 |
if [ $PSI ]; then
|
|
|
353 |
sed -i "s|^EXTRA_OPTIONS=.*|EXTRA_OPTIONS='-fakestat -memcache'|" /etc/sysconfig/afs
|
|
|
354 |
else
|
81 |
beyerle@PS |
355 |
# for SL4
|
1 |
beyerle@PS |
356 |
grep -q "\-fakestat \-memcache" /etc/sysconfig/afs
|
|
|
357 |
if [ "$?" != "0" ]; then
|
|
|
358 |
sed -i "s|-fakestat|-fakestat -memcache|" /etc/sysconfig/afs
|
|
|
359 |
fi
|
81 |
beyerle@PS |
360 |
# for SL5
|
|
|
361 |
rpm -q openafs | grep -q SL5
|
|
|
362 |
if [ "$?" = "0" ]; then
|
|
|
363 |
sed -i "s|^OPTIONS=.*|OPTIONS=\"-memcache\"|" /etc/sysconfig/afs
|
|
|
364 |
fi
|
1 |
beyerle@PS |
365 |
fi
|
|
|
366 |
fi
|
|
|
367 |
|
|
|
368 |
### source /etc/sysconfig/cfengine
|
|
|
369 |
[ $PSI ] && . /etc/sysconfig/cfengine
|
|
|
370 |
|
|
|
371 |
### Set /etc/motd
|
23 |
beyerle@PS |
372 |
LiveCD="LiveCD"
|
|
|
373 |
[ "$ARCH" = "x86_64" ] && LiveCD="LiveCD 64bit"
|
|
|
374 |
echo "Welcome to $LIVECD_OS ${LiveCD}" > /etc/motd
|
|
|
375 |
[ $PSI ] && echo "Welcome to PSI ${LiveCD} (${CLASS} ${SUBCLASS} SL${RELEASE})" > /etc/motd
|
68 |
beyerle@PS |
376 |
[ $DVD ] && sed -i "s|CD|DVD|" /etc/motd
|
|
|
377 |
[ $MINI ] && sed -i "s|CD|MiniCD|" /etc/motd
|
1 |
beyerle@PS |
378 |
|
|
|
379 |
### Set hostname to psi or slinux (not really necessary)
|
|
|
380 |
if [ $PSI ]; then
|
|
|
381 |
HOSTNAME="psi"
|
|
|
382 |
sed -i "s/hostname=.*/hostname=${HOSTNAME}.psi.ch/" /etc/ssmtp/ssmtp.conf
|
|
|
383 |
sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/cfengine
|
|
|
384 |
else
|
23 |
beyerle@PS |
385 |
HOSTNAME="$DEFAULT_HOSTNAME"
|
|
|
386 |
fi
|
1 |
beyerle@PS |
387 |
|
|
|
388 |
# change hostname
|
|
|
389 |
sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/network
|
|
|
390 |
sed -i "s/DHCP_HOSTNAME=.*/DHCP_HOSTNAME==${HOSTNAME}/" /etc/sysconfig/networking/devices/ifcfg-eth0 2>/dev/null
|
|
|
391 |
|
|
|
392 |
### Modify /etc/redhat-release
|
93 |
beyerle@PS |
393 |
ADD=" - LiveCD"
|
|
|
394 |
[ $DVD ] && ADD=" - LiveDVD"
|
|
|
395 |
[ $MINI ] && ADD=" - LiveMiniCD"
|
|
|
396 |
if [ -e /etc/redhat-release.ori ]; then
|
|
|
397 |
echo "$( cat /etc/redhat-release.ori )${ADD}" > /etc/redhat-release
|
1 |
beyerle@PS |
398 |
fi
|
|
|
399 |
|
|
|
400 |
### set default runlevel to $RUNLEVEL
|
|
|
401 |
if [ $RUNLEVEL ]; then
|
|
|
402 |
sed -i "s/id:.:initdefault:/id:$RUNLEVEL:initdefault:/" /etc/inittab
|
|
|
403 |
fi
|
|
|
404 |
|
|
|
405 |
### edit /etc/sysconfig/desktop
|
|
|
406 |
if [ $DESKTOP ]; then
|
|
|
407 |
sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
|
|
|
408 |
echo "DESKTOP=$DESKTOP" >> /etc/sysconfig/desktop
|
|
|
409 |
fi
|
|
|
410 |
if [ $DISPLAYMANAGER ]; then
|
|
|
411 |
sed -i "/^DISPLAYMANAGER=.*/d" /etc/sysconfig/desktop 2&>/dev/null
|
|
|
412 |
echo "DISPLAYMANAGER=$DISPLAYMANAGER" >> /etc/sysconfig/desktop
|
|
|
413 |
fi
|
|
|
414 |
|
|
|
415 |
### GDM login background
|
|
|
416 |
if [ -e /usr/share/gdm/themes/SL/background.png ]; then
|
|
|
417 |
cp -a customize/sl${OS_RELEASE}/background.png /usr/share/gdm/themes/SL/background.png
|
|
|
418 |
fi
|
|
|
419 |
|
|
|
420 |
### KDE default background
|
|
|
421 |
if [ ! $PSI ]; then
|
|
|
422 |
if [ -e /usr/share/backgrounds/images/default.png ]; then
|
|
|
423 |
cp -a customize/sl${OS_RELEASE}/default.png /usr/share/backgrounds/images/default.png
|
|
|
424 |
fi
|
|
|
425 |
fi
|
|
|
426 |
|
|
|
427 |
### KDE startup/exit sound
|
|
|
428 |
if [ -e /usr/share/config/knotify.eventsrc ]; then
|
|
|
429 |
cp -a customize/sl/knotify.eventsrc /usr/share/config/knotify.eventsrc
|
|
|
430 |
cp -a customize/sl/kmixrc /usr/share/config/kmixrc
|
|
|
431 |
fi
|
|
|
432 |
|
|
|
433 |
### KDE session manager; start at login
|
|
|
434 |
# kmix, krandrtray
|
74 |
beyerle@PS |
435 |
# if [ -e /usr/share/config/ksmserverrc ]; then
|
|
|
436 |
# cp -a customize/sl/ksmserverrc /usr/share/config/ksmserverrc
|
|
|
437 |
# fi
|
|
|
438 |
#
|
|
|
439 |
## now done in runlast by coping .desktop files to .kde/Autostart
|
|
|
440 |
#
|
1 |
beyerle@PS |
441 |
|
|
|
442 |
### Configure SELinux
|
|
|
443 |
if [ $SELINUX ]; then
|
|
|
444 |
if [ -e /etc/selinux/config ]; then
|
|
|
445 |
sed -i "s|^SELINUX=.*|SELINUX=$SELINUX|" /etc/selinux/config
|
|
|
446 |
fi
|
|
|
447 |
fi
|
|
|
448 |
|
|
|
449 |
### Do not like jumping CD icon when starting autorun.desktop
|
|
|
450 |
if [ -e /etc/skel/.kde/Autostart/Autorun.desktop ]; then
|
|
|
451 |
grep -q "StartupNotify=false" /etc/skel/.kde/Autostart/Autorun.desktop
|
|
|
452 |
if [ "$?" != "0" ]; then
|
|
|
453 |
echo "StartupNotify=false" >> /etc/skel/.kde/Autostart/Autorun.desktop
|
|
|
454 |
fi
|
|
|
455 |
fi
|
|
|
456 |
|
|
|
457 |
echo "done."
|
|
|
458 |
echo "--------------------------------------------"
|
|
|
459 |
|
|
|
460 |
|
|
|
461 |
|
|
|
462 |
###############################################################
|
|
|
463 |
# Add-ons
|
|
|
464 |
###############################################################
|
|
|
465 |
|
|
|
466 |
echo "Add-ons ..."
|
|
|
467 |
|
|
|
468 |
### System icon on desktop
|
|
|
469 |
if [ -d /usr/share/apps/kdesktop/DesktopLinks ]; then
|
|
|
470 |
cp -a customize/System.desktop /usr/share/apps/kdesktop/DesktopLinks/
|
|
|
471 |
fi
|
|
|
472 |
|
|
|
473 |
### files for PSI User, will be copied during bootup to /home/$LOCALUSER/
|
|
|
474 |
if [ $PSI ]; then
|
|
|
475 |
rm -rf /usr/share/$LOCALUSER
|
|
|
476 |
cp -a customize/$LOCALUSER /usr/share/
|
|
|
477 |
fi
|
|
|
478 |
|
|
|
479 |
### psi-menu, psi-scanvirus
|
|
|
480 |
if [ $PSI ]; then
|
|
|
481 |
cp -a customize/psi/psi-menu /usr/bin/
|
|
|
482 |
cp -a customize/psi/psi-scanvirus /usr/bin/
|
|
|
483 |
[ -d /usr/local/uvscan ] && cp -a customize/psi/update-dat /usr/local/uvscan/
|
|
|
484 |
[ -x /usr/bin/freshclam ] && cp -a customize/psi/psi-freshclam /usr/bin/
|
|
|
485 |
fi
|
|
|
486 |
|
23 |
beyerle@PS |
487 |
### script to install LiveCD on local harddisk
|
31 |
beyerle@PS |
488 |
cp -a customize/livecd-install /usr/bin/
|
16 |
beyerle@PS |
489 |
|
52 |
beyerle@PS |
490 |
### GUI for livecd-install
|
55 |
beyerle@PS |
491 |
cp -a customize/livecd-install-gui/livecd-install-gui /usr/sbin/
|
66 |
beyerle@PS |
492 |
ln -fs consolehelper /usr/bin/livecd-install-gui
|
55 |
beyerle@PS |
493 |
cp -a customize/livecd-install-gui/livecd-install-gui.desktop /usr/share/applications/
|
|
|
494 |
cp -a customize/livecd-install-gui/livecd-install-gui.console.apps /etc/security/console.apps/livecd-install-gui
|
|
|
495 |
cp -a customize/livecd-install-gui/livecd-install-gui.pam.d /etc/pam.d/livecd-install-gui
|
52 |
beyerle@PS |
496 |
|
23 |
beyerle@PS |
497 |
### livecd-mkinitrd (used by livecd-install)
|
20 |
beyerle@PS |
498 |
if [ -e customize/sl${OS_RELEASE}/livecd-mkinitrd ]; then
|
|
|
499 |
cp -a customize/sl${OS_RELEASE}/livecd-mkinitrd /usr/sbin/
|
|
|
500 |
else
|
|
|
501 |
cp -a /sbin/mkinitrd /usr/sbin/livecd-mkinitrd
|
|
|
502 |
fi
|
|
|
503 |
|
|
|
504 |
|
1 |
beyerle@PS |
505 |
echo "done."
|
|
|
506 |
echo "--------------------------------------------"
|
|
|
507 |
|
|
|
508 |
|
110 |
beyerle@PS |
509 |
###############################################################
|
|
|
510 |
# Create missing files
|
|
|
511 |
###############################################################
|
1 |
beyerle@PS |
512 |
|
110 |
beyerle@PS |
513 |
echo "Create missing files ..."
|
|
|
514 |
|
1 |
beyerle@PS |
515 |
###############################################################
|
110 |
beyerle@PS |
516 |
# /etc/hosts
|
|
|
517 |
### copy host file, if not existing
|
|
|
518 |
[ -e /etc/hosts ] || cp -a customize/hosts /etc/hosts
|
|
|
519 |
[ -e /etc/sysconfig/networking/profiles/default/hosts ] || cp -a customize/hosts /etc/sysconfig/networking/profiles/default/hosts
|
|
|
520 |
|
|
|
521 |
|
|
|
522 |
###############################################################
|
|
|
523 |
# /etc/shadow
|
115 |
beyerle@PS |
524 |
if [ ! -e /etc/shadow ]; then
|
|
|
525 |
sed -i "s|\*|x|" /etc/passwd
|
|
|
526 |
sed -i "s|^root::|root:x:|" /etc/passwd
|
|
|
527 |
cat /etc/passwd | cut -d":" -f 1 | while read u; do echo "$u:*:12345:0:99999:1:::"; done >> /etc/shadow
|
|
|
528 |
chmod 600 /etc/shadow
|
|
|
529 |
fi
|
110 |
beyerle@PS |
530 |
|
|
|
531 |
# /etc/gshadow
|
|
|
532 |
if [ ! -e /etc/gshadow ]; then
|
|
|
533 |
cp -a /etc/group /etc/gshadow
|
|
|
534 |
sed -i "s|:x:|::|" /etc/gshadow
|
|
|
535 |
sed -i "s|:[0-9]\+:|::|" /etc/gshadow
|
115 |
beyerle@PS |
536 |
chmod 600 /etc/gshadow
|
110 |
beyerle@PS |
537 |
fi
|
|
|
538 |
|
|
|
539 |
echo "done."
|
|
|
540 |
echo "--------------------------------------------"
|
|
|
541 |
|
|
|
542 |
|
|
|
543 |
|
|
|
544 |
###############################################################
|
1 |
beyerle@PS |
545 |
# Create special files
|
|
|
546 |
###############################################################
|
|
|
547 |
|
|
|
548 |
echo "Create special files ..."
|
|
|
549 |
|
|
|
550 |
###############################################################
|
|
|
551 |
# /etc/rc.d/init.d/kudzu-auto
|
|
|
552 |
### Noninteractive HW detection and configuration
|
|
|
553 |
|
|
|
554 |
cp -a customize/kudzu-auto /etc/init.d/kudzu-auto
|
|
|
555 |
chmod +x /etc/rc.d/init.d/kudzu-auto
|
|
|
556 |
ln -sf /etc/rc.d/init.d/kudzu-auto /etc/rc.d/rc5.d/S04kudzu-auto
|
|
|
557 |
ln -sf /etc/rc.d/init.d/kudzu-auto /etc/rc.d/rc3.d/S04kudzu-auto
|
|
|
558 |
|
|
|
559 |
|
|
|
560 |
###############################################################
|
|
|
561 |
# /etc/rc.d/init.d/runveryfirst
|
|
|
562 |
### Fix some things during bootup - run VERY first
|
|
|
563 |
# runveryfirst will run at the begining of /etc/rc.d/rc.sysinit
|
|
|
564 |
|
|
|
565 |
cp -a customize/runveryfirst /etc/init.d/runveryfirst
|
|
|
566 |
chmod +x /etc/rc.d/init.d/runveryfirst
|
|
|
567 |
|
|
|
568 |
# execute runveryfirst just before "Initialize hardware"
|
|
|
569 |
grep -q runveryfirst /etc/rc.d/rc.sysinit
|
|
|
570 |
if [ "$?" != "0" ]; then
|
|
|
571 |
sed -i -e "/^# Initialize hardware/a\/etc\/init.d\/runveryfirst" /etc/rc.d/rc.sysinit
|
|
|
572 |
fi
|
|
|
573 |
|
|
|
574 |
|
|
|
575 |
###############################################################
|
|
|
576 |
# /etc/rc.d/init.d/runfirst
|
|
|
577 |
### Fix some things during bootup - run first
|
|
|
578 |
# runfirst will run at the end of /etc/rc.d/rc.sysinit
|
|
|
579 |
|
|
|
580 |
cp -a customize/runfirst /etc/init.d/runfirst
|
|
|
581 |
chmod +x /etc/rc.d/init.d/runfirst
|
|
|
582 |
|
|
|
583 |
sysinit_line="/etc/rc.d/init.d/runfirst"
|
|
|
584 |
grep -q "$sysinit_line" /etc/rc.d/rc.sysinit
|
|
|
585 |
if [ "$?" != "0" ]; then
|
|
|
586 |
echo "$sysinit_line" >> /etc/rc.d/rc.sysinit
|
|
|
587 |
echo >> /etc/rc.d/rc.sysinit
|
|
|
588 |
fi
|
|
|
589 |
|
14 |
beyerle@PS |
590 |
|
1 |
beyerle@PS |
591 |
###############################################################
|
|
|
592 |
# /etc/rc.d/init.d/runlast
|
|
|
593 |
### Fix some things during bootup - run last
|
|
|
594 |
|
|
|
595 |
cp -a customize/runlast /etc/init.d/runlast
|
|
|
596 |
chmod +x /etc/rc.d/init.d/runlast
|
|
|
597 |
|
|
|
598 |
### Add /etc/rc.d/init.d/runlast to rc.local
|
|
|
599 |
LINE=/etc/rc.d/init.d/runlast
|
|
|
600 |
grep -q $LINE /etc/rc.d/rc.local
|
|
|
601 |
if [ "$?" != "0" ]; then
|
|
|
602 |
# add line
|
|
|
603 |
echo "" >> /etc/rc.d/rc.local
|
|
|
604 |
echo $LINE >> /etc/rc.d/rc.local
|
|
|
605 |
echo "" >> /etc/rc.d/rc.local
|
|
|
606 |
fi
|
|
|
607 |
|
14 |
beyerle@PS |
608 |
|
1 |
beyerle@PS |
609 |
###############################################################
|
|
|
610 |
# /usr/bin/save-localdata
|
|
|
611 |
### stores data on a usbstick
|
|
|
612 |
cp -a customize/save-localdata /usr/bin/save-localdata
|
|
|
613 |
chmod +x /usr/bin/save-localdata
|
|
|
614 |
|
|
|
615 |
# add /usr/bin/save-localdata to /etc/sudoers
|
79 |
beyerle@PS |
616 |
if [ -e /etc/sudoers ]; then
|
|
|
617 |
grep -q "save-localdata" /etc/sudoers 2>/dev/null
|
|
|
618 |
if [ "$?" != "0" ]; then
|
|
|
619 |
cp -a /etc/sudoers /etc/sudoers.ori
|
|
|
620 |
echo "$LOCALUSER ALL = NOPASSWD: /usr/bin/save-localdata" >> /etc/sudoers
|
|
|
621 |
fi
|
1 |
beyerle@PS |
622 |
fi
|
|
|
623 |
|
|
|
624 |
# create menu entry
|
|
|
625 |
cp -a customize/save-localdata.desktop /usr/share/applications/
|
|
|
626 |
|
14 |
beyerle@PS |
627 |
|
1 |
beyerle@PS |
628 |
###############################################################
|
|
|
629 |
# /usr/bin/set-volume
|
|
|
630 |
### unmute all mixers and set volumes
|
|
|
631 |
cp -a customize/set-volume /usr/bin/set-volume
|
|
|
632 |
chmod +x /usr/bin/set-volume
|
|
|
633 |
|
14 |
beyerle@PS |
634 |
|
1 |
beyerle@PS |
635 |
###############################################################
|
|
|
636 |
# /etc/sysconfig/networking/devices/ifcfg-eth0
|
|
|
637 |
# /etc/sysconfig/networking/devices/ifcfg-eth1
|
|
|
638 |
|
|
|
639 |
for iface in eth0 eth1; do
|
|
|
640 |
|
|
|
641 |
# remove it first
|
|
|
642 |
rm -f /etc/sysconfig/networking/devices/ifcfg-${iface} 2>/dev/null
|
|
|
643 |
rm -f /etc/sysconfig/networking/profiles/default/ifcfg-${iface} 2>/dev/null
|
|
|
644 |
rm -f /etc/sysconfig/network-scripts/ifcfg-${iface} 2>/dev/null
|
|
|
645 |
|
|
|
646 |
# create it, if we have a sample
|
|
|
647 |
if [ -e customize/sl${OS_RELEASE}/ifcfg-${iface} ]; then
|
|
|
648 |
cp -a customize/sl${OS_RELEASE}/ifcfg-${iface} /etc/sysconfig/networking/devices/ifcfg-${iface}
|
|
|
649 |
# make hard links
|
|
|
650 |
cp -lf /etc/sysconfig/networking/devices/ifcfg-${iface} /etc/sysconfig/networking/profiles/default/
|
|
|
651 |
cp -lf /etc/sysconfig/networking/devices/ifcfg-${iface} /etc/sysconfig/network-scripts/
|
|
|
652 |
fi
|
|
|
653 |
done
|
|
|
654 |
|
|
|
655 |
|
|
|
656 |
###############################################################
|
|
|
657 |
# /etc/profile.d/setsysfont.sh
|
|
|
658 |
### setsysfont
|
|
|
659 |
cat > /etc/profile.d/setsysfont.sh <<EOF
|
|
|
660 |
# setsysfont once
|
|
|
661 |
if [ ! -e /tmp/.sysfont_has_been_set ]; then
|
|
|
662 |
touch /tmp/.sysfont_has_been_set
|
|
|
663 |
/bin/setfont 2>/dev/null
|
|
|
664 |
/sbin/setsysfont 2>/dev/null
|
|
|
665 |
fi
|
|
|
666 |
EOF
|
|
|
667 |
chmod 755 /etc/profile.d/setsysfont.sh
|
|
|
668 |
|
14 |
beyerle@PS |
669 |
|
1 |
beyerle@PS |
670 |
###############################################################
|
|
|
671 |
# /etc/profile.d/setsysfont.csh
|
|
|
672 |
### setsysfont
|
|
|
673 |
cat > /etc/profile.d/setsysfont.csh <<EOF
|
|
|
674 |
# setsysfont once
|
|
|
675 |
if ( ! -e /tmp/.sysfont_has_been_set ) then
|
|
|
676 |
touch /tmp/.sysfont_has_been_set
|
|
|
677 |
/bin/setfont 2>/dev/null
|
|
|
678 |
/sbin/setsysfont 2>/dev/null
|
|
|
679 |
endif
|
|
|
680 |
EOF
|
|
|
681 |
chmod 755 /etc/profile.d/setsysfont.csh
|
|
|
682 |
|
14 |
beyerle@PS |
683 |
|
1 |
beyerle@PS |
684 |
###############################################################
|
|
|
685 |
# /etc/cron.d/psi
|
|
|
686 |
### PSI specific cronjobs
|
|
|
687 |
|
14 |
beyerle@PS |
688 |
if [ $PSI ]; then
|
|
|
689 |
cp -a customize/psi/cron_psi /etc/cron.d/psi
|
|
|
690 |
chmod +x /etc/cron.d/psi
|
1 |
beyerle@PS |
691 |
fi
|
|
|
692 |
|
|
|
693 |
echo "done."
|
|
|
694 |
echo "--------------------------------------------"
|
|
|
695 |
|
|
|
696 |
|
|
|
697 |
|
|
|
698 |
###############################################################
|
|
|
699 |
# Configure services
|
|
|
700 |
###############################################################
|
|
|
701 |
|
|
|
702 |
echo "Configure services ..."
|
|
|
703 |
|
23 |
beyerle@PS |
704 |
### services off
|
1 |
beyerle@PS |
705 |
|
|
|
706 |
if [ $PSI ]; then
|
|
|
707 |
chkconfig cfenvd off 2>/dev/null
|
|
|
708 |
chkconfig cfexecd off 2>/dev/null
|
|
|
709 |
chkconfig cfservd off 2>/dev/null
|
|
|
710 |
fi
|
|
|
711 |
if [ ! "$SERVICES_OFF" = "" ]; then
|
|
|
712 |
for service in $SERVICES_OFF; do
|
|
|
713 |
chkconfig $service off 2>/dev/null
|
|
|
714 |
done
|
|
|
715 |
fi
|
|
|
716 |
# we do kudzu-auto
|
|
|
717 |
chkconfig kudzu off
|
|
|
718 |
|
|
|
719 |
|
23 |
beyerle@PS |
720 |
### services on
|
1 |
beyerle@PS |
721 |
|
|
|
722 |
if [ $PSI ]; then
|
|
|
723 |
chkconfig vpnclient_init on 2>/dev/null
|
|
|
724 |
fi
|
|
|
725 |
if [ ! "$SERVICES_ON" = "" ]; then
|
|
|
726 |
for service in $SERVICES_ON; do
|
|
|
727 |
chkconfig $service on 2>/dev/null
|
|
|
728 |
done
|
|
|
729 |
fi
|
|
|
730 |
|
|
|
731 |
echo "done."
|
|
|
732 |
echo "--------------------------------------------"
|
|
|
733 |
|
|
|
734 |
|
|
|
735 |
###############################################################
|
|
|
736 |
# Empty files
|
|
|
737 |
###############################################################
|
|
|
738 |
|
|
|
739 |
echo "Empty files ..."
|
|
|
740 |
|
|
|
741 |
### /etc/security/users
|
|
|
742 |
if [ $PSI ]; then
|
|
|
743 |
rm -f /etc/security/users
|
|
|
744 |
touch /etc/security/users
|
|
|
745 |
fi
|
|
|
746 |
|
|
|
747 |
### Files to empty
|
|
|
748 |
FILES_TOUCH="/etc/sysconfig/hwconf \
|
|
|
749 |
/etc/resolv.conf \
|
|
|
750 |
/etc/adjtime \
|
|
|
751 |
/etc/modprobe.conf \
|
|
|
752 |
/etc/dhclient-eth0.conf"
|
|
|
753 |
|
|
|
754 |
for file in $FILES_TOUCH; do
|
|
|
755 |
rm -rf $file
|
|
|
756 |
touch $file
|
|
|
757 |
done
|
|
|
758 |
|
|
|
759 |
echo "done."
|
|
|
760 |
echo "--------------------------------------------"
|
|
|
761 |
|
|
|
762 |
|
110 |
beyerle@PS |
763 |
|
1 |
beyerle@PS |
764 |
###############################################################
|
|
|
765 |
# Update locate db, prelink, makewhatis
|
|
|
766 |
###############################################################
|
|
|
767 |
|
95 |
beyerle@PS |
768 |
### run updatedb
|
1 |
beyerle@PS |
769 |
if [ -x /usr/bin/updatedb ]; then
|
|
|
770 |
echo "Run updatedb..."
|
|
|
771 |
. /etc/updatedb.conf 2>/dev/null
|
|
|
772 |
rpm -q mlocate >/dev/null
|
|
|
773 |
if [ "$?" = "0" ]; then
|
41 |
beyerle@PS |
774 |
/usr/bin/updatedb -e "/media /sfs /tmp /boot /livecd /home /net /trunk"
|
1 |
beyerle@PS |
775 |
else
|
41 |
beyerle@PS |
776 |
/usr/bin/updatedb -e /media,/tmp,/boot,/livecd,/home,/net,/trunk
|
1 |
beyerle@PS |
777 |
fi
|
|
|
778 |
echo "done."
|
|
|
779 |
fi
|
|
|
780 |
|
|
|
781 |
### run prelink
|
|
|
782 |
if [ -x /etc/cron.daily/prelink ]; then
|
|
|
783 |
echo "Run prelink..."
|
|
|
784 |
/etc/cron.daily/prelink
|
|
|
785 |
echo "done."
|
|
|
786 |
fi
|
|
|
787 |
if [ -x /etc/cron_backup/prelink ]; then
|
|
|
788 |
echo "Run prelink..."
|
|
|
789 |
/etc/cron_backup/prelink
|
|
|
790 |
echo "done."
|
|
|
791 |
fi
|
23 |
beyerle@PS |
792 |
|
|
|
793 |
### clean prelink log
|
1 |
beyerle@PS |
794 |
rm -f /var/log/prelink/prelink.log 2>/dev/null
|
|
|
795 |
rm -f /var/log/prelink.log 2>/dev/null
|
|
|
796 |
|
|
|
797 |
### run makewhatis
|
|
|
798 |
if [ -x /usr/bin/makewhatis ]; then
|
|
|
799 |
echo "Run makewhatis..."
|
|
|
800 |
makewhatis -u -w
|
|
|
801 |
fi
|
|
|
802 |
|
|
|
803 |
echo "done."
|
|
|
804 |
echo "--------------------------------------------"
|
|
|
805 |
|
|
|
806 |
###############################################################
|