Subversion Repositories livecd

Rev

Rev 307 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
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
#
169 beyerle@PS 10
# Urs Beyerle
1 beyerle@PS 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
134 beyerle@PS 103
dkms status -m nvidia 2>/dev/null | grep -q nvidia
104
if [ "$?" = "0" ]; then
135 beyerle@PS 105
    # already built?
106
    dkms status -m nvidia -k $KERNEL | grep installed
107
    if [ "$?" != "0" ]; then
151 beyerle@PS 108
	module_version=$( dkms status -m nvidia | cut -d"," -f2 | cut -d":" -f1 )
135 beyerle@PS 109
	dkms build -m nvidia -v $module_version -k $KERNEL
110
	dkms install -m nvidia -v $module_version -k $KERNEL
111
    fi
134 beyerle@PS 112
fi
1 beyerle@PS 113
 
114
# build vpnclient kernel module
134 beyerle@PS 115
running_kernel=$( uname -r )
116
if [ -x /usr/sbin/mkvpnclient ]; then
117
    if [ "$running_kernel" = "$KERNEL" ]; then
118
	mkvpnclient
119
    else
152 beyerle@PS 120
	if [ -e /lib/modules/$KERNEL/CiscoVPN/cisco_ipsec.ko ]; then
121
	    echo "VPN client kernel module found."
122
	    sleep 2
123
	else
124
	    echo "VPN client kernel module could not be build ..."
125
	    sleep 5
126
	fi
134 beyerle@PS 127
    fi
128
fi
1 beyerle@PS 129
 
130
# Update Virus definitions 
131
# run freshclam
132
if [ -x /usr/bin/freshclam ]; then
133
    echo; echo "Run /usr/bin/freshclam:"
134
    /etc/init.d/clamd status || /etc/init.d/clamd start && /usr/bin/freshclam
135
    /etc/init.d/clamd stop
136
    echo
137
fi
138
# update f-prot and uvscan
139
[ -x /usr/local/f-prot/tools/check-updates.pl ] && /usr/local/f-prot/tools/check-updates.pl
140
[ -x /usr/local/uvscan/update-dat ] && /usr/local/uvscan/update-dat
141
 
142
# run depmod -a for the LiveCD kernels
125 beyerle@PS 143
echo "Run depmod -a $KERNEL ..."
144
depmod -a $KERNEL
1 beyerle@PS 145
if [ $SMP ]; then
146
    echo "Run depmod -a ${KERNEL}smp ..."
147
    depmod -a ${KERNEL}smp
148
fi
149
 
150
# delete users (just to be sure)
151
userdel -r $LOCALUSER 2>/dev/null
152
userdel -r l_psi 2>/dev/null
153
userdel -r sluser 2>/dev/null
154
userdel -r user 2>/dev/null
155
 
125 beyerle@PS 156
# copy back /etc/yum.repos.d.ori to /etc/yum.repos.d
157
if [ -d /etc/yum.repos.d.ori ]; then
158
    cp -a /etc/yum.repos.d.ori /etc/yum.repos.d
1 beyerle@PS 159
fi
160
 
161
echo "done."
162
echo "--------------------------------------------"
163
 
164
 
165
 
166
###############################################################
167
# Clean up and delete files
168
###############################################################
169
 
170
echo "Cleaning up ..."
171
 
172
### set LANG
173
export LANG=C
174
 
175
### stop AFS
176
/etc/init.d/afs stop 2>/dev/null
177
 
178
### clean up yum
179
yum clean all >/dev/null
180
rm -rf /var/cache/yum/*
181
 
182
### remove cfengine log files
183
rm -f /var/cfengine/*log
184
 
185
### delete log files
186
find /var/log/ -type f -exec rm -f {} \;
187
 
125 beyerle@PS 188
### clean rpm database cache
1 beyerle@PS 189
rm -rf /var/lib/rpm/__db.*
190
 
191
### clean /var/spool/mail
192
rm -rf /var/spool/mail/*
193
touch /var/spool/mail/root
194
chmod 600 /var/spool/mail/root
195
 
196
### delete .rpmori .rpm Files in /etc
197
find /etc -name "*\.rpmorig" -exec rm -f {} \;
198
find /etc -name "*\.rpmnew"  -exec rm -f {} \;
29 beyerle@PS 199
find /etc -name "*\.rpmsave" -exec rm -f {} \;
1 beyerle@PS 200
 
201
### delete *~ files in /etc
202
find /etc | grep "~$" | while read f; do rm -f "$f"; done
203
 
204
### clean up /root
56 beyerle@PS 205
rm -f  /root/.bash_history
154 beyerle@PS 206
rm -f  /root/.lesshst
207
rm -f  /root/.rnd
162 beyerle@PS 208
rm -rf /root/.emacs.d
56 beyerle@PS 209
rm -f  /root/.ssh/known_hosts
210
rm -rf /root/.subversion
1 beyerle@PS 211
 
212
### clean AFS cache
213
if [ -d /usr/vice/cache ]; then
214
    rm -rf /usr/vice/cache
215
    mkdir /usr/vice/cache
216
fi
217
if [ -d /var/cache/openafs ]; then
218
    rm -rf /var/cache/openafs
219
    mkdir /var/cache/openafs
220
fi
221
 
222
### clean up /var/tmp
223
rm -rf /var/tmp/*
224
 
225
### remove root passwd
226
sed -i "s|^root:.*|root:\*:12943:0:99999:7:::|" /etc/shadow
227
sed -i "s|^root:.*:0:0|root:x:0:0|" /etc/passwd
228
 
229
### remove /.autofsck
23 beyerle@PS 230
rm -f /.autofsck
1 beyerle@PS 231
 
125 beyerle@PS 232
### disable cfagent 
233
[ $PSI ] && mv /etc/cron.d/cfengine      /etc/cron_backup/ 2>/dev/null
1 beyerle@PS 234
 
125 beyerle@PS 235
### disable psi-cronjobs
236
[ $PSI ] && mv /etc/cron.d/psi-cronjobs  /etc/cron_backup/ 2>/dev/null
237
 
238
### disable check_update
23 beyerle@PS 239
[ $PSI ] && sed -i "s|/etc/init.d/check_update|# /etc/init.d/check_update|" /etc/rc.d/rc.local.psi
125 beyerle@PS 240
[ $PSI ] && chkconfig check_update off
1 beyerle@PS 241
 
242
### create in /boot link to LiveCD kernel(s)
243
ln -fs /boot/vmlinuz-$KERNEL /boot/vmlinuz
244
[ $SMP ] && ln -fs /boot/vmlinuz-${KERNEL}smp /boot/vmlinuz${SMP}
245
 
110 beyerle@PS 246
### remove ssh keys
1 beyerle@PS 247
FILES_REMOVE="/etc/ssh/ssh_host_key \
248
              /etc/ssh/ssh_host_key.pub \
249
              /etc/ssh/ssh_host_rsa_key.pub \
250
              /etc/ssh/ssh_host_dsa_key \
251
              /etc/ssh/ssh_host_dsa_key.pub"
252
for file in $FILES_REMOVE; do
23 beyerle@PS 253
    rm -f $file
1 beyerle@PS 254
done
255
 
256
### remove useless cronjobs
257
mkdir -p /etc/cron_backup
125 beyerle@PS 258
mv /etc/cron.d/sysstat                 /etc/cron_backup/ 2>/dev/null
1 beyerle@PS 259
mv /etc/cron.weekly/00-makewhatis.cron /etc/cron_backup/00-makewhatis.cron.weekly 2>/dev/null
125 beyerle@PS 260
mv /etc/cron.daily/00-makewhatis.cron  /etc/cron_backup/ 2>/dev/null
261
mv /etc/cron.daily/makewhatis.cron     /etc/cron_backup/ 2>/dev/null
262
mv /etc/cron.daily/rpm                 /etc/cron_backup/ 2>/dev/null
263
mv /etc/cron.daily/slocate.cron        /etc/cron_backup/ 2>/dev/null
264
mv /etc/cron.daily/tetex.cron          /etc/cron_backup/ 2>/dev/null
265
mv /etc/cron.daily/yum.cron            /etc/cron_backup/ 2>/dev/null
266
mv /etc/cron.daily/prelink             /etc/cron_backup/ 2>/dev/null
1 beyerle@PS 267
 
268
### remove backup of /etc/X11/xorg.conf
125 beyerle@PS 269
rm -f /etc/X11/xorg.conf.ori    2>/dev/null
1 beyerle@PS 270
rm -f /etc/X11/xorg.conf.backup 2>/dev/null
271
 
272
### remove unused dirs in /lib/modules
273
ls /lib/modules/ | grep -v $KERNEL | while read mod_dir; do
274
    rpm -qf --quiet /lib/modules/$mod_dir
275
    if [ $? != "0" ]; then
276
	if [ $mod_dir != "" ]; then
277
	    cleaned_dir=/tmp/cleaned-$( date +%Y%m%d%H%M )
278
	    mkdir -p $cleaned_dir
279
            echo "Move dir /lib/modules/$mod_dir to $cleaned_dir"
280
	    mv -f /lib/modules/$mod_dir $cleaned_dir/
281
        fi
282
    fi
283
done
230 beyerleu 284
 
1 beyerle@PS 285
### move some unneeded files to /mini (not for LiveDVD and miniCD)
110 beyerle@PS 286
#   to save disk space
287
 
1 beyerle@PS 288
if [ ! $DVD ] && [ ! $MINI ]; then
289
 
230 beyerleu 290
    echo "Move some folders to /mini, to save disk space:"
1 beyerle@PS 291
    mkdir -p /mini
292
 
293
    # move some dirs in /usr/share/doc to /mini
294
    mkdir -p /mini/usr/share/doc
255 beyerleu 295
    mv -v /usr/share/doc/bash-*           /mini/usr/share/doc 2>/dev/null
115 beyerle@PS 296
    mv -v /usr/share/doc/cups-*           /mini/usr/share/doc 2>/dev/null
307 beyerleu 297
    mv -v /usr/share/doc/dialog-*         /mini/usr/share/doc 2>/dev/null    
115 beyerle@PS 298
    mv -v /usr/share/doc/exim-*           /mini/usr/share/doc 2>/dev/null
307 beyerleu 299
    mv -v /usr/share/doc/foomatic-*       /mini/usr/share/doc 2>/dev/null
255 beyerleu 300
    mv -v /usr/share/doc/gawk-*           /mini/usr/share/doc 2>/dev/null
301
    mv -v /usr/share/doc/gcc-*            /mini/usr/share/doc 2>/dev/null
302
    mv -v /usr/share/doc/gdm-*            /mini/usr/share/doc 2>/dev/null
80 beyerle@PS 303
    mv -v /usr/share/doc/ghostscript-*    /mini/usr/share/doc 2>/dev/null
255 beyerleu 304
    mv -v /usr/share/doc/gnome-vfs2-*     /mini/usr/share/doc 2>/dev/null
80 beyerle@PS 305
    mv -v /usr/share/doc/gnuplot-*        /mini/usr/share/doc 2>/dev/null
255 beyerleu 306
    mv -v /usr/share/doc/initscripts-*    /mini/usr/share/doc 2>/dev/null
307
    mv -v /usr/share/doc/iproute-*        /mini/usr/share/doc 2>/dev/null
307 beyerleu 308
    mv -v /usr/share/doc/lame-*           /mini/usr/share/doc 2>/dev/null
255 beyerleu 309
    mv -v /usr/share/doc/libsigc++20-*    /mini/usr/share/doc 2>/dev/null
307 beyerleu 310
    mv -v /usr/share/doc/libxslt-*        /mini/usr/share/doc 2>/dev/null
255 beyerleu 311
    mv -v /usr/share/doc/m2crypto-*       /mini/usr/share/doc 2>/dev/null
312
    mv -v /usr/share/doc/ntp-*            /mini/usr/share/doc 2>/dev/null
313
    mv -v /usr/share/doc/openafs-*        /mini/usr/share/doc 2>/dev/null
307 beyerleu 314
    mv -v /usr/share/doc/pam-*            /mini/usr/share/doc 2>/dev/null
255 beyerleu 315
    mv -v /usr/share/doc/pine-*           /mini/usr/share/doc 2>/dev/null
307 beyerleu 316
    mv -v /usr/share/doc/pygtk2-*         /mini/usr/share/doc 2>/dev/null
255 beyerleu 317
    mv -v /usr/share/doc/htdig-*          /mini/usr/share/doc 2>/dev/null
80 beyerle@PS 318
    mv -v /usr/share/doc/ImageMagick-*    /mini/usr/share/doc 2>/dev/null
319
    mv -v /usr/share/doc/isdn4k-utils-*   /mini/usr/share/doc 2>/dev/null
335 beyerleu 320
    mv -v /usr/share/doc/rpm-*            /mini/usr/share/doc 2>/dev/null
307 beyerleu 321
    mv -v /usr/share/doc/rsyslog-*        /mini/usr/share/doc 2>/dev/null
80 beyerle@PS 322
    mv -v /usr/share/doc/sane-backends-*  /mini/usr/share/doc 2>/dev/null
215 beyerleu 323
    mv -v /usr/share/doc/selinux-policy-* /mini/usr/share/doc 2>/dev/null
255 beyerleu 324
    mv -v /usr/share/doc/testdisk-*       /mini/usr/share/doc 2>/dev/null
307 beyerleu 325
    mv -v /usr/share/doc/xdialog-*        /mini/usr/share/doc 2>/dev/null
117 beyerle@PS 326
 
327
    mkdir -p /mini/usr/share/backgrounds/images
328
    mv -v /usr/share/backgrounds/images/*.gz /mini/usr/share/backgrounds/images/ 2>/dev/null
73 beyerle@PS 329
 
255 beyerleu 330
    mkdir -p /mini/usr/share/anaconda/pixmaps
331
    mv -v /usr/share/anaconda/pixmaps/rnotes /mini/usr/share/anaconda/pixmaps/
332
 
333
    # move zipped java source, demo, sample to /mini, if j2sdk is installed
334
    java_src=$( rpm -ql j2sdk 2>/dev/null | grep /src.zip$ )
80 beyerle@PS 335
    [ -e "$java_src" ] && mv -v "$java_src" /mini/
255 beyerleu 336
    java_demo=$( rpm -ql j2sdk | grep /demo$ | head -n 1 )
337
    [ -e "$java_demo" ] && mv -v "$java_demo" /mini/ 
338
    java_sample=$( rpm -ql j2sdk | grep /sample$ | head -n 1 )
339
    [ -e "$java_sample" ] && mv -v "$java_sample" /mini/ 
340
 
341
    # move zipped java source, demo, sample to /mini, if jdk is installed
342
    java_src=$( rpm -ql jdk 2>/dev/null | grep /src.zip$ )
343
    [ -e "$java_src" ] && mv -v "$java_src" /mini/
344
    java_demo=$( rpm -ql jdk | grep /demo$ | head -n 1 )
345
    [ -e "$java_demo" ] && mv -v "$java_demo" /mini/ 
346
    java_sample=$( rpm -ql jdk | grep /sample$ | head -n 1 )
347
    [ -e "$java_sample" ] && mv -v "$java_sample" /mini/ 
335 beyerleu 348
 
349
    # move mysql info to /mini
350
    mkdir -p /mini/usr/share/info
351
    mv -v /usr/share/info/mysql.info.gz /mini/usr/share/info 2>/dev/null
80 beyerle@PS 352
 
1 beyerle@PS 353
fi
354
 
355
echo "done."
356
echo "--------------------------------------------"
357
 
358
 
359
 
360
###############################################################
361
# Modify files
362
###############################################################
363
 
364
echo "Modify files ..."
365
 
211 beyerleu 366
### create /etc/sysconfig/clock, if not existing
367
if [ ! -e /etc/sysconfig/clock ]; then
368
    echo "UTC=false" >> /etc/sysconfig/clock
369
    echo "ARC=false" >> /etc/sysconfig/clock
370
fi
371
 
1 beyerle@PS 372
### remove AFS startup warning about cache
23 beyerle@PS 373
[ $PSI ] && sed  -i "/\!\!\!/d" /etc/init.d/afs
1 beyerle@PS 374
 
375
### disable umount of loop device during shutdown
376
#   this is done really dirty at the moment:
377
#    -> just replace "loop" with non existing device "lo_fake"
378
 
379
[ -e /etc/init.d/netfs ]     && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/netfs
380
[ -e /etc/init.d/autofs ]    && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/autofs
381
[ -e /etc/init.d/halt ]      && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/halt
382
[ -e /etc/init.d/functions ] && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/functions
383
 
384
# do not shuttdown loopback interface
385
sed -i "s|[^#]action \$\"Shutting down loopback interface:|\t#action \$\"Shutting down loopback interface:|" /etc/init.d/network
386
 
153 beyerle@PS 387
### suppress error message of already mounted devpts when doing mount -a
388
sed -i "s|mount -a -t nonfs,nfs4,smbfs,cifs,ncpfs,gfs$|mount -a -t nonfs,nfs4,smbfs,cifs,ncpfs,gfs 2>/dev/null|" /etc/init.d/netfs
389
 
1 beyerle@PS 390
### copy new /etc/init.d/halt 
391
cp -a customize/sl${OS_RELEASE}/halt /etc/init.d/halt
392
 
393
### in /etc/rc.d/rc.sysinit
394
#   comment out 'initlog -c "fsck -T -a $rootdev $fsckoptions"' 
395
#   to disable fsck of root filesystem
396
sed -i "s|\tfsck -T -a \$rootdev|\tsleep 0; #fsck -T -a \$rootdev|" /etc/rc.d/rc.sysinit
397
sed -i "s|\tinitlog -c \"fsck -T -a \$rootdev|\tsleep 0; #initlog -c \"fsck -T -a \$rootdev|" /etc/rc.d/rc.sysinit
398
#   disable "Remounting root filesystem in read-write mode"
153 beyerle@PS 399
sed -i "s| action \$\"Remounting root filesystem| sleep 0; #action \$\"Remounting root filesystem|" /etc/rc.d/rc.sysinit
1 beyerle@PS 400
 
401
### start afs with option -memcache !
402
if [ -e /etc/sysconfig/afs ]; then
403
    if [ $PSI ]; then
404
	sed -i "s|^EXTRA_OPTIONS=.*|EXTRA_OPTIONS='-fakestat -memcache'|" /etc/sysconfig/afs
125 beyerle@PS 405
	sed -i "s|ENABLE_MEMCACHE='no'|ENABLE_MEMCACHE='yes'|" /etc/sysconfig/afs
1 beyerle@PS 406
    else
81 beyerle@PS 407
	# for SL4
1 beyerle@PS 408
	grep -q "\-fakestat \-memcache" /etc/sysconfig/afs
409
	if [ "$?" != "0" ]; then
410
	    sed -i "s|-fakestat|-fakestat -memcache|" /etc/sysconfig/afs
411
	fi
81 beyerle@PS 412
	# for SL5
413
	rpm -q openafs | grep -q SL5
414
	if [ "$?" = "0" ]; then
415
	    sed -i "s|^OPTIONS=.*|OPTIONS=\"-memcache\"|" /etc/sysconfig/afs
416
	fi
1 beyerle@PS 417
    fi
418
fi
419
 
125 beyerle@PS 420
### source /etc/sysconfig/psi
421
[ $PSI ] && . /etc/sysconfig/psi
1 beyerle@PS 422
 
423
### Set /etc/motd
23 beyerle@PS 424
LiveCD="LiveCD"
425
[ "$ARCH" = "x86_64" ] && LiveCD="LiveCD 64bit"
426
echo "Welcome to $LIVECD_OS ${LiveCD}" > /etc/motd
427
[ $PSI ] && echo "Welcome to PSI ${LiveCD} (${CLASS} ${SUBCLASS} SL${RELEASE})" > /etc/motd
68 beyerle@PS 428
[ $DVD ]  && sed -i "s|CD|DVD|"    /etc/motd
429
[ $MINI ] && sed -i "s|CD|MiniCD|" /etc/motd
1 beyerle@PS 430
 
431
### Set hostname to psi or slinux (not really necessary)
432
if [ $PSI ]; then
433
    HOSTNAME="psi"
434
    sed -i "s/hostname=.*/hostname=${HOSTNAME}.psi.ch/" /etc/ssmtp/ssmtp.conf
125 beyerle@PS 435
    sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/psi
1 beyerle@PS 436
else
23 beyerle@PS 437
    HOSTNAME="$DEFAULT_HOSTNAME"
438
fi
1 beyerle@PS 439
 
125 beyerle@PS 440
### Change hostname
1 beyerle@PS 441
sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/network
442
sed -i "s/DHCP_HOSTNAME=.*/DHCP_HOSTNAME==${HOSTNAME}/" /etc/sysconfig/networking/devices/ifcfg-eth0 2>/dev/null
443
 
444
### Modify /etc/redhat-release
93 beyerle@PS 445
ADD=" - LiveCD"
446
[ $DVD ]  && ADD=" - LiveDVD"
447
[ $MINI ] && ADD=" - LiveMiniCD"
448
if [ -e /etc/redhat-release.ori ]; then
449
    echo "$( cat /etc/redhat-release.ori )${ADD}" > /etc/redhat-release
1 beyerle@PS 450
fi
451
 
125 beyerle@PS 452
### Set default runlevel to $RUNLEVEL
1 beyerle@PS 453
if [ $RUNLEVEL ]; then
454
    sed -i "s/id:.:initdefault:/id:$RUNLEVEL:initdefault:/" /etc/inittab
455
fi
456
 
125 beyerle@PS 457
### Edit /etc/sysconfig/desktop
1 beyerle@PS 458
if [ $DESKTOP ]; then
459
    sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
460
    echo "DESKTOP=$DESKTOP" >> /etc/sysconfig/desktop
461
fi
462
if [ $DISPLAYMANAGER ]; then
463
    sed -i "/^DISPLAYMANAGER=.*/d" /etc/sysconfig/desktop 2&>/dev/null
464
    echo "DISPLAYMANAGER=$DISPLAYMANAGER" >> /etc/sysconfig/desktop
465
fi
466
 
467
### GDM login background
468
if [ -e /usr/share/gdm/themes/SL/background.png ]; then
469
    cp -a customize/sl${OS_RELEASE}/background.png /usr/share/gdm/themes/SL/background.png
470
fi
471
 
472
### KDE default background
473
if [ ! $PSI ]; then
474
    if [ -e /usr/share/backgrounds/images/default.png ]; then
475
	cp -a customize/sl${OS_RELEASE}/default.png /usr/share/backgrounds/images/default.png
476
    fi
477
fi
478
 
479
### KDE startup/exit sound
480
if [ -e /usr/share/config/knotify.eventsrc ]; then
481
    cp -a customize/sl/knotify.eventsrc /usr/share/config/knotify.eventsrc
482
    cp -a customize/sl/kmixrc /usr/share/config/kmixrc
483
fi
484
 
485
### Configure SELinux
486
if [ $SELINUX ]; then
487
    if [ -e /etc/selinux/config ]; then
488
	sed -i "s|^SELINUX=.*|SELINUX=$SELINUX|" /etc/selinux/config
489
    fi
490
fi
491
 
492
### Do not like jumping CD icon when starting autorun.desktop
493
if [ -e /etc/skel/.kde/Autostart/Autorun.desktop ]; then
494
    grep -q "StartupNotify=false" /etc/skel/.kde/Autostart/Autorun.desktop
495
    if [ "$?" != "0" ]; then
496
	echo "StartupNotify=false" >> /etc/skel/.kde/Autostart/Autorun.desktop
497
    fi
498
fi
499
 
239 beyerleu 500
### make thunderbird the default mail application in launchmail, if evolution is not installed
501
#   (I don't like launchmail )
154 beyerle@PS 502
rpm -q evolution >/dev/null 2>&1
503
if [ "$?" = "1" ]; then
504
    rpm -q thunderbird >/dev/null 2>&1
505
    if [ "$?" = "0" ]; then
239 beyerleu 506
	if [ ! -L /usr/bin/launchmail ]; then
507
	    mv /usr/bin/launchmail /usr/bin/launchmail.ori
508
	    ln -s /usr/bin/thunderbird /usr/bin/launchmail
509
	fi
154 beyerle@PS 510
    fi
511
fi
512
 
215 beyerleu 513
### fix a bug in dag's gparted
514
if [ -e /usr/bin/run-gparted ]; then
515
    grep -q "/bin/bash" /usr/bin/run-gparted
516
    if [ "$?" != "0" ]; then
517
	echo '#!/bin/bash'        > /usr/bin/run-gparted
518
	echo '/usr/sbin/gparted' >> /usr/bin/run-gparted
519
	chmod 755 /usr/bin/run-gparted
520
    fi
521
fi
522
 
1 beyerle@PS 523
echo "done."
524
echo "--------------------------------------------"
525
 
526
 
527
 
528
###############################################################
529
# Add-ons
530
###############################################################
531
 
532
echo "Add-ons ..."
533
 
534
### System icon on desktop
535
if [ -d /usr/share/apps/kdesktop/DesktopLinks ]; then
536
    cp -a customize/System.desktop /usr/share/apps/kdesktop/DesktopLinks/
537
fi
538
 
230 beyerleu 539
### configure ICEWM
258 beyerleu 540
cp -a customize/icewm/winoptions /usr/share/icewm/ 2>/dev/null
541
cp -a customize/icewm/toolbar /usr/share/icewm/    2>/dev/null
542
cp -a customize/icewm/menu /usr/share/icewm/       2>/dev/null
1 beyerle@PS 543
 
230 beyerleu 544
### set SL theme as default theme for ICEWM
545
rpm -q icewm-SL-theme >/dev/null 2>&1
546
if [ "$?" = "0" ]; then
547
    echo "Theme=SL/default.theme" > /usr/share/icewm/theme
1 beyerle@PS 548
fi
549
 
230 beyerleu 550
### icons for icewm
551
cp -a /usr/share/pixmaps/qtparted.xpm /usr/share/icewm/icons/ 2>/dev/null
552
cp -a /usr/share/gftp/gftp.xpm /usr/share/icewm/icons/ 2>/dev/null
553
 
23 beyerle@PS 554
### script to install LiveCD on local harddisk
31 beyerle@PS 555
cp -a customize/livecd-install  /usr/bin/
16 beyerle@PS 556
 
52 beyerle@PS 557
### GUI for livecd-install
55 beyerle@PS 558
cp -a customize/livecd-install-gui/livecd-install-gui /usr/sbin/
66 beyerle@PS 559
ln -fs consolehelper /usr/bin/livecd-install-gui
55 beyerle@PS 560
cp -a customize/livecd-install-gui/livecd-install-gui.desktop /usr/share/applications/
561
cp -a customize/livecd-install-gui/livecd-install-gui.console.apps /etc/security/console.apps/livecd-install-gui
562
cp -a customize/livecd-install-gui/livecd-install-gui.pam.d /etc/pam.d/livecd-install-gui
52 beyerle@PS 563
 
23 beyerle@PS 564
### livecd-mkinitrd (used by livecd-install)
20 beyerle@PS 565
if [ -e customize/sl${OS_RELEASE}/livecd-mkinitrd ]; then
566
    cp -a customize/sl${OS_RELEASE}/livecd-mkinitrd /usr/sbin/
567
else
568
    cp -a /sbin/mkinitrd /usr/sbin/livecd-mkinitrd
569
fi
570
 
231 beyerleu 571
### /usr/sbin/livecd-autologin, provides directly login over xinit
572
cp -a customize/livecd-autologin /usr/sbin/livecd-autologin
573
chmod +x /usr/sbin/livecd-autologin
574
 
230 beyerleu 575
### files for PSI User, will be copied during bootup to /home/$LOCALUSER/
576
if [ $PSI ]; then
577
    rm -rf /usr/share/$LOCALUSER
578
    cp -a customize/$LOCALUSER /usr/share/
579
fi
20 beyerle@PS 580
 
230 beyerleu 581
### psi-menu, psi-scanvirus
582
if [ $PSI ]; then
583
    cp -a customize/psi/psi-menu /usr/bin/
584
    cp -a customize/psi/psi-scanvirus /usr/bin/
585
    [ -d /usr/local/uvscan ] && cp -a customize/psi/update-dat /usr/local/uvscan/
586
    [ -x /usr/bin/freshclam ] && cp -a customize/psi/psi-freshclam /usr/bin/
587
fi
588
 
1 beyerle@PS 589
echo "done."
590
echo "--------------------------------------------"
591
 
592
 
110 beyerle@PS 593
###############################################################
594
# Create missing files
595
###############################################################
1 beyerle@PS 596
 
110 beyerle@PS 597
echo "Create missing files ..."
598
 
1 beyerle@PS 599
###############################################################
110 beyerle@PS 600
# /etc/hosts
601
### copy host file, if not existing
602
[ -e /etc/hosts ] || cp -a customize/hosts /etc/hosts
603
[ -e /etc/sysconfig/networking/profiles/default/hosts ] || cp -a customize/hosts /etc/sysconfig/networking/profiles/default/hosts
604
 
605
 
606
###############################################################
607
# /etc/shadow
115 beyerle@PS 608
if [ ! -e /etc/shadow ]; then
609
    sed -i "s|\*|x|" /etc/passwd
610
    sed -i "s|^root::|root:x:|" /etc/passwd
611
    cat /etc/passwd | cut -d":" -f 1 | while read u; do echo "$u:*:12345:0:99999:1:::"; done >> /etc/shadow
612
    chmod 600 /etc/shadow
613
fi
110 beyerle@PS 614
 
615
# /etc/gshadow
616
if [ ! -e /etc/gshadow ]; then
617
    cp -a /etc/group /etc/gshadow
618
    sed -i "s|:x:|::|"       /etc/gshadow
619
    sed -i "s|:[0-9]\+:|::|" /etc/gshadow
115 beyerle@PS 620
    chmod 600 /etc/gshadow
110 beyerle@PS 621
fi
622
 
623
echo "done."
624
echo "--------------------------------------------"
625
 
626
 
627
 
628
###############################################################
1 beyerle@PS 629
# Create special files
630
###############################################################
631
 
632
echo "Create special files ..."
633
 
634
###############################################################
635
# /etc/rc.d/init.d/kudzu-auto
636
### Noninteractive HW detection and configuration
637
 
128 beyerle@PS 638
cp -a customize/kudzu-auto /etc/rc.d/init.d/kudzu-auto
1 beyerle@PS 639
chmod +x /etc/rc.d/init.d/kudzu-auto
128 beyerle@PS 640
chkconfig --add kudzu-auto
641
chkconfig kudzu-auto on
1 beyerle@PS 642
 
643
 
644
###############################################################
645
# /etc/rc.d/init.d/runveryfirst
646
### Fix some things during bootup - run VERY first
647
# runveryfirst will run at the begining of /etc/rc.d/rc.sysinit
648
 
649
cp -a customize/runveryfirst /etc/init.d/runveryfirst
650
chmod +x /etc/rc.d/init.d/runveryfirst
651
 
652
# execute runveryfirst just before "Initialize hardware"
653
grep -q runveryfirst /etc/rc.d/rc.sysinit
654
if [ "$?" != "0" ]; then
655
    sed -i -e "/^# Initialize hardware/a\/etc\/init.d\/runveryfirst" /etc/rc.d/rc.sysinit
656
fi
657
 
658
 
659
###############################################################
660
# /etc/rc.d/init.d/runfirst
661
### Fix some things during bootup - run first
662
# runfirst will run at the end of /etc/rc.d/rc.sysinit
663
 
664
cp -a customize/runfirst /etc/init.d/runfirst
665
chmod +x /etc/rc.d/init.d/runfirst
666
 
667
sysinit_line="/etc/rc.d/init.d/runfirst"
668
grep -q "$sysinit_line" /etc/rc.d/rc.sysinit
669
if [ "$?" != "0" ]; then
670
    echo "$sysinit_line" >> /etc/rc.d/rc.sysinit
671
    echo >> /etc/rc.d/rc.sysinit
672
fi
673
 
14 beyerle@PS 674
 
1 beyerle@PS 675
###############################################################
676
# /etc/rc.d/init.d/runlast
677
### Fix some things during bootup - run last
678
 
679
cp -a customize/runlast /etc/init.d/runlast
680
chmod +x /etc/rc.d/init.d/runlast
681
 
682
### Add /etc/rc.d/init.d/runlast to rc.local
683
LINE=/etc/rc.d/init.d/runlast
684
grep -q $LINE /etc/rc.d/rc.local
685
if [ "$?" != "0" ]; then
686
    # add line
687
    echo "" >> /etc/rc.d/rc.local
688
    echo $LINE >> /etc/rc.d/rc.local
689
    echo "" >> /etc/rc.d/rc.local    
690
fi
691
 
14 beyerle@PS 692
 
1 beyerle@PS 693
###############################################################
694
# /usr/bin/save-localdata
695
### stores data on a usbstick
696
cp -a customize/save-localdata /usr/bin/save-localdata
697
chmod +x /usr/bin/save-localdata
698
 
699
# add /usr/bin/save-localdata to /etc/sudoers
79 beyerle@PS 700
if [ -e /etc/sudoers ]; then
701
    grep -q "save-localdata" /etc/sudoers 2>/dev/null
702
    if [ "$?" != "0" ]; then
703
	cp -a /etc/sudoers /etc/sudoers.ori
704
	echo "$LOCALUSER ALL = NOPASSWD: /usr/bin/save-localdata" >> /etc/sudoers
705
    fi
1 beyerle@PS 706
fi
707
 
708
# create menu entry
709
cp -a customize/save-localdata.desktop /usr/share/applications/
710
 
14 beyerle@PS 711
 
1 beyerle@PS 712
###############################################################
713
# /usr/bin/set-volume
714
### unmute all mixers and set volumes
715
cp -a customize/set-volume /usr/bin/set-volume
716
chmod +x /usr/bin/set-volume
717
 
14 beyerle@PS 718
 
1 beyerle@PS 719
###############################################################
720
# /etc/sysconfig/networking/devices/ifcfg-eth0
721
# /etc/sysconfig/networking/devices/ifcfg-eth1
722
 
723
for iface in eth0 eth1; do 
724
 
725
    # remove it first
726
    rm -f /etc/sysconfig/networking/devices/ifcfg-${iface} 2>/dev/null
727
    rm -f /etc/sysconfig/networking/profiles/default/ifcfg-${iface} 2>/dev/null
728
    rm -f /etc/sysconfig/network-scripts/ifcfg-${iface} 2>/dev/null
729
 
730
    # create it, if we have a sample
731
    if [ -e customize/sl${OS_RELEASE}/ifcfg-${iface} ]; then
732
	cp -a customize/sl${OS_RELEASE}/ifcfg-${iface} /etc/sysconfig/networking/devices/ifcfg-${iface}
733
        # make hard links
734
	cp -lf /etc/sysconfig/networking/devices/ifcfg-${iface} /etc/sysconfig/networking/profiles/default/
735
	cp -lf /etc/sysconfig/networking/devices/ifcfg-${iface} /etc/sysconfig/network-scripts/
736
    fi
737
done
738
 
739
 
740
###############################################################
741
# /etc/profile.d/setsysfont.sh
742
### setsysfont 
743
cat > /etc/profile.d/setsysfont.sh <<EOF
744
# setsysfont once
745
if [ ! -e /tmp/.sysfont_has_been_set ]; then
746
    touch /tmp/.sysfont_has_been_set
747
    /bin/setfont 2>/dev/null
748
    /sbin/setsysfont 2>/dev/null
749
fi
750
EOF
751
chmod 755 /etc/profile.d/setsysfont.sh
752
 
14 beyerle@PS 753
 
1 beyerle@PS 754
###############################################################
755
# /etc/profile.d/setsysfont.csh
756
### setsysfont 
757
cat > /etc/profile.d/setsysfont.csh <<EOF
758
# setsysfont once
759
if ( ! -e /tmp/.sysfont_has_been_set ) then
760
    touch /tmp/.sysfont_has_been_set
761
    /bin/setfont 2>/dev/null
762
    /sbin/setsysfont 2>/dev/null
763
endif
764
EOF
765
chmod 755 /etc/profile.d/setsysfont.csh
766
 
14 beyerle@PS 767
 
1 beyerle@PS 768
###############################################################
769
# /etc/cron.d/psi
770
### PSI specific cronjobs
771
 
125 beyerle@PS 772
if [ $PSI ] && [ -e customize/psi/cron_psi.sl${OS_RELEASE} ]; then
773
    cp -a customize/psi/cron_psi.sl${OS_RELEASE} /etc/cron.d/psi 
14 beyerle@PS 774
    chmod +x /etc/cron.d/psi
1 beyerle@PS 775
fi
776
 
777
echo "done."
778
echo "--------------------------------------------"
779
 
780
 
781
 
782
###############################################################
783
# Configure services
784
###############################################################
785
 
786
echo "Configure services ..."
787
 
23 beyerle@PS 788
### services off
1 beyerle@PS 789
if [ $PSI ]; then
125 beyerle@PS 790
    chkconfig cfenvd off  2>/dev/null
1 beyerle@PS 791
    chkconfig cfexecd off 2>/dev/null
792
    chkconfig cfservd off 2>/dev/null
793
fi
794
if [ ! "$SERVICES_OFF" = "" ]; then
795
    for service in $SERVICES_OFF; do
796
	chkconfig $service off 2>/dev/null
797
    done
798
fi
125 beyerle@PS 799
 
800
### we do kudzu-auto
1 beyerle@PS 801
chkconfig kudzu off 
802
 
23 beyerle@PS 803
### services on
1 beyerle@PS 804
if [ ! "$SERVICES_ON" = "" ]; then
805
    for service in $SERVICES_ON; do
806
	chkconfig $service on 2>/dev/null
807
    done
808
fi
809
 
810
echo "done."
811
echo "--------------------------------------------"
812
 
813
 
814
###############################################################
815
# Empty files
816
###############################################################
817
 
818
echo "Empty files ..."
819
 
820
### /etc/security/users
821
if [ $PSI ]; then
125 beyerle@PS 822
    rm -f /etc/security/ssh.allow
823
    touch /etc/security/ssh.allow
1 beyerle@PS 824
fi
825
 
826
### Files to empty
827
FILES_TOUCH="/etc/sysconfig/hwconf \
828
             /etc/resolv.conf \
829
             /etc/adjtime \
830
             /etc/modprobe.conf \
831
             /etc/dhclient-eth0.conf"
832
 
833
for file in $FILES_TOUCH; do
834
    rm -rf $file
835
    touch $file
836
done
837
 
838
echo "done."
839
echo "--------------------------------------------"
840
 
841
 
110 beyerle@PS 842
 
1 beyerle@PS 843
###############################################################
844
# Update locate db, prelink, makewhatis
845
###############################################################
846
 
95 beyerle@PS 847
### run updatedb
1 beyerle@PS 848
if [ -x /usr/bin/updatedb ]; then
849
    echo "Run updatedb..."
850
    . /etc/updatedb.conf 2>/dev/null
851
    rpm -q mlocate >/dev/null
852
    if [ "$?" = "0" ]; then
41 beyerle@PS 853
	/usr/bin/updatedb -e "/media /sfs /tmp /boot /livecd /home /net /trunk"
1 beyerle@PS 854
    else
41 beyerle@PS 855
	/usr/bin/updatedb -e /media,/tmp,/boot,/livecd,/home,/net,/trunk
1 beyerle@PS 856
    fi
857
    echo "done."
858
fi
859
 
860
### run prelink
861
if [ -x /etc/cron.daily/prelink ]; then
862
    echo "Run prelink..."
863
    /etc/cron.daily/prelink
864
    echo "done."
865
fi
866
if [ -x /etc/cron_backup/prelink ]; then
867
    echo "Run prelink..."
868
    /etc/cron_backup/prelink
869
    echo "done."
870
fi
23 beyerle@PS 871
 
872
### clean prelink log
1 beyerle@PS 873
rm -f /var/log/prelink/prelink.log 2>/dev/null
874
rm -f /var/log/prelink.log 2>/dev/null
875
 
876
### run makewhatis
125 beyerle@PS 877
which makewhatis >/dev/null 2>&1
878
if [ "$?" = "0" ]; then
1 beyerle@PS 879
    echo "Run makewhatis..."
880
    makewhatis -u -w
881
fi
882
 
883
echo "done."
884
echo "--------------------------------------------"
885
 
886
###############################################################