Subversion Repositories livecd

Rev

Rev 134 | Rev 151 | Go to most recent revision | 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
#
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
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
108
	module_version=$( dkms status -m nvidia | cut -d"," -f2 )
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
135 beyerle@PS 120
	echo -n "VPN client kernel module could not be build. Is it installed? "
121
	sleep 5; echo
134 beyerle@PS 122
    fi
123
fi
1 beyerle@PS 124
 
125
# Update Virus definitions 
126
# run freshclam
127
if [ -x /usr/bin/freshclam ]; then
128
    echo; echo "Run /usr/bin/freshclam:"
129
    /etc/init.d/clamd status || /etc/init.d/clamd start && /usr/bin/freshclam
130
    /etc/init.d/clamd stop
131
    echo
132
fi
133
# update f-prot and uvscan
134
[ -x /usr/local/f-prot/tools/check-updates.pl ] && /usr/local/f-prot/tools/check-updates.pl
135
[ -x /usr/local/uvscan/update-dat ] && /usr/local/uvscan/update-dat
136
 
137
# run depmod -a for the LiveCD kernels
125 beyerle@PS 138
echo "Run depmod -a $KERNEL ..."
139
depmod -a $KERNEL
1 beyerle@PS 140
if [ $SMP ]; then
141
    echo "Run depmod -a ${KERNEL}smp ..."
142
    depmod -a ${KERNEL}smp
143
fi
144
 
145
# delete users (just to be sure)
146
userdel -r $LOCALUSER 2>/dev/null
147
userdel -r l_psi 2>/dev/null
148
userdel -r sluser 2>/dev/null
149
userdel -r user 2>/dev/null
150
 
125 beyerle@PS 151
# copy back /etc/yum.repos.d.ori to /etc/yum.repos.d
152
if [ -d /etc/yum.repos.d.ori ]; then
153
    cp -a /etc/yum.repos.d.ori /etc/yum.repos.d
1 beyerle@PS 154
fi
155
 
156
echo "done."
157
echo "--------------------------------------------"
158
 
159
 
160
 
161
###############################################################
162
# Clean up and delete files
163
###############################################################
164
 
165
echo "Cleaning up ..."
166
 
167
### set LANG
168
export LANG=C
169
 
170
### stop AFS
171
/etc/init.d/afs stop 2>/dev/null
172
 
173
### clean up yum
174
yum clean all >/dev/null
175
rm -rf /var/cache/yum/*
176
 
177
### remove cfengine log files
178
rm -f /var/cfengine/*log
179
 
180
### delete log files
181
find /var/log/ -type f -exec rm -f {} \;
182
 
125 beyerle@PS 183
### clean rpm database cache
1 beyerle@PS 184
rm -rf /var/lib/rpm/__db.*
185
 
186
### clean /var/spool/mail
187
rm -rf /var/spool/mail/*
188
touch /var/spool/mail/root
189
chmod 600 /var/spool/mail/root
190
 
191
### delete .rpmori .rpm Files in /etc
192
find /etc -name "*\.rpmorig" -exec rm -f {} \;
193
find /etc -name "*\.rpmnew"  -exec rm -f {} \;
29 beyerle@PS 194
find /etc -name "*\.rpmsave" -exec rm -f {} \;
1 beyerle@PS 195
 
196
### delete *~ files in /etc
197
find /etc | grep "~$" | while read f; do rm -f "$f"; done
198
 
199
### clean up /root
56 beyerle@PS 200
rm -f  /root/.bash_history
201
rm -f  /root/.ssh/known_hosts
202
rm -rf /root/.subversion
1 beyerle@PS 203
 
204
### clean AFS cache
205
if [ -d /usr/vice/cache ]; then
206
    rm -rf /usr/vice/cache
207
    mkdir /usr/vice/cache
208
fi
209
if [ -d /var/cache/openafs ]; then
210
    rm -rf /var/cache/openafs
211
    mkdir /var/cache/openafs
212
fi
213
 
214
### clean up /var/tmp
215
rm -rf /var/tmp/*
216
 
217
### remove root passwd
218
sed -i "s|^root:.*|root:\*:12943:0:99999:7:::|" /etc/shadow
219
sed -i "s|^root:.*:0:0|root:x:0:0|" /etc/passwd
220
 
221
### remove /.autofsck
23 beyerle@PS 222
rm -f /.autofsck
1 beyerle@PS 223
 
125 beyerle@PS 224
### disable cfagent 
225
[ $PSI ] && mv /etc/cron.d/cfengine      /etc/cron_backup/ 2>/dev/null
1 beyerle@PS 226
 
125 beyerle@PS 227
### disable psi-cronjobs
228
[ $PSI ] && mv /etc/cron.d/psi-cronjobs  /etc/cron_backup/ 2>/dev/null
229
 
230
### disable check_update
23 beyerle@PS 231
[ $PSI ] && sed -i "s|/etc/init.d/check_update|# /etc/init.d/check_update|" /etc/rc.d/rc.local.psi
125 beyerle@PS 232
[ $PSI ] && chkconfig check_update off
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
125 beyerle@PS 250
mv /etc/cron.d/sysstat                 /etc/cron_backup/ 2>/dev/null
1 beyerle@PS 251
mv /etc/cron.weekly/00-makewhatis.cron /etc/cron_backup/00-makewhatis.cron.weekly 2>/dev/null
125 beyerle@PS 252
mv /etc/cron.daily/00-makewhatis.cron  /etc/cron_backup/ 2>/dev/null
253
mv /etc/cron.daily/makewhatis.cron     /etc/cron_backup/ 2>/dev/null
254
mv /etc/cron.daily/rpm                 /etc/cron_backup/ 2>/dev/null
255
mv /etc/cron.daily/slocate.cron        /etc/cron_backup/ 2>/dev/null
256
mv /etc/cron.daily/tetex.cron          /etc/cron_backup/ 2>/dev/null
257
mv /etc/cron.daily/yum.cron            /etc/cron_backup/ 2>/dev/null
258
mv /etc/cron.daily/prelink             /etc/cron_backup/ 2>/dev/null
1 beyerle@PS 259
 
260
### remove backup of /etc/X11/xorg.conf
125 beyerle@PS 261
rm -f /etc/X11/xorg.conf.ori    2>/dev/null
1 beyerle@PS 262
rm -f /etc/X11/xorg.conf.backup 2>/dev/null
263
 
264
### remove unused dirs in /lib/modules
265
ls /lib/modules/ | grep -v $KERNEL | while read mod_dir; do
266
    rpm -qf --quiet /lib/modules/$mod_dir
267
    if [ $? != "0" ]; then
268
	if [ $mod_dir != "" ]; then
269
	    cleaned_dir=/tmp/cleaned-$( date +%Y%m%d%H%M )
270
	    mkdir -p $cleaned_dir
271
            echo "Move dir /lib/modules/$mod_dir to $cleaned_dir"
272
	    mv -f /lib/modules/$mod_dir $cleaned_dir/
273
        fi
274
    fi
275
done
276
 
277
### move some unneeded files to /mini (not for LiveDVD and miniCD)
110 beyerle@PS 278
#   to save disk space
279
 
1 beyerle@PS 280
if [ ! $DVD ] && [ ! $MINI ]; then
281
 
282
    mkdir -p /mini
283
 
80 beyerle@PS 284
    echo "Move some folders to /mini, to save disk space:"
285
 
1 beyerle@PS 286
    # move some dirs in /usr/share/doc to /mini
287
    mkdir -p /mini/usr/share/doc
115 beyerle@PS 288
    mv -v /usr/share/doc/openafs-*        /mini/usr/share/doc 2>/dev/null
289
    mv -v /usr/share/doc/gcc-*            /mini/usr/share/doc 2>/dev/null
290
    mv -v /usr/share/doc/pine-*           /mini/usr/share/doc 2>/dev/null
291
    mv -v /usr/share/doc/ntp-*            /mini/usr/share/doc 2>/dev/null
292
    mv -v /usr/share/doc/cups-*           /mini/usr/share/doc 2>/dev/null
293
    mv -v /usr/share/doc/testdisk-*       /mini/usr/share/doc 2>/dev/null
294
    mv -v /usr/share/doc/htdig-*          /mini/usr/share/doc 2>/dev/null
295
    mv -v /usr/share/doc/gnome-vfs2-*     /mini/usr/share/doc 2>/dev/null
296
    mv -v /usr/share/doc/bash-*           /mini/usr/share/doc 2>/dev/null
297
    mv -v /usr/share/doc/exim-*           /mini/usr/share/doc 2>/dev/null
80 beyerle@PS 298
    mv -v /usr/share/doc/ghostscript-*    /mini/usr/share/doc 2>/dev/null
299
    mv -v /usr/share/doc/gnuplot-*        /mini/usr/share/doc 2>/dev/null
300
    mv -v /usr/share/doc/ImageMagick-*    /mini/usr/share/doc 2>/dev/null
301
    mv -v /usr/share/doc/isdn4k-utils-*   /mini/usr/share/doc 2>/dev/null
302
    mv -v /usr/share/doc/sane-backends-*  /mini/usr/share/doc 2>/dev/null
117 beyerle@PS 303
 
304
    mkdir -p /mini/usr/share/backgrounds/images
305
    mv -v /usr/share/backgrounds/images/*.gz /mini/usr/share/backgrounds/images/ 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
125 beyerle@PS 354
	sed -i "s|ENABLE_MEMCACHE='no'|ENABLE_MEMCACHE='yes'|" /etc/sysconfig/afs
1 beyerle@PS 355
    else
81 beyerle@PS 356
	# for SL4
1 beyerle@PS 357
	grep -q "\-fakestat \-memcache" /etc/sysconfig/afs
358
	if [ "$?" != "0" ]; then
359
	    sed -i "s|-fakestat|-fakestat -memcache|" /etc/sysconfig/afs
360
	fi
81 beyerle@PS 361
	# for SL5
362
	rpm -q openafs | grep -q SL5
363
	if [ "$?" = "0" ]; then
364
	    sed -i "s|^OPTIONS=.*|OPTIONS=\"-memcache\"|" /etc/sysconfig/afs
365
	fi
1 beyerle@PS 366
    fi
367
fi
368
 
125 beyerle@PS 369
### source /etc/sysconfig/psi
370
[ $PSI ] && . /etc/sysconfig/psi
1 beyerle@PS 371
 
372
### Set /etc/motd
23 beyerle@PS 373
LiveCD="LiveCD"
374
[ "$ARCH" = "x86_64" ] && LiveCD="LiveCD 64bit"
375
echo "Welcome to $LIVECD_OS ${LiveCD}" > /etc/motd
376
[ $PSI ] && echo "Welcome to PSI ${LiveCD} (${CLASS} ${SUBCLASS} SL${RELEASE})" > /etc/motd
68 beyerle@PS 377
[ $DVD ]  && sed -i "s|CD|DVD|"    /etc/motd
378
[ $MINI ] && sed -i "s|CD|MiniCD|" /etc/motd
1 beyerle@PS 379
 
380
### Set hostname to psi or slinux (not really necessary)
381
if [ $PSI ]; then
382
    HOSTNAME="psi"
383
    sed -i "s/hostname=.*/hostname=${HOSTNAME}.psi.ch/" /etc/ssmtp/ssmtp.conf
125 beyerle@PS 384
    sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/psi
1 beyerle@PS 385
else
23 beyerle@PS 386
    HOSTNAME="$DEFAULT_HOSTNAME"
387
fi
1 beyerle@PS 388
 
125 beyerle@PS 389
### Change hostname
1 beyerle@PS 390
sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/network
391
sed -i "s/DHCP_HOSTNAME=.*/DHCP_HOSTNAME==${HOSTNAME}/" /etc/sysconfig/networking/devices/ifcfg-eth0 2>/dev/null
392
 
393
### Modify /etc/redhat-release
93 beyerle@PS 394
ADD=" - LiveCD"
395
[ $DVD ]  && ADD=" - LiveDVD"
396
[ $MINI ] && ADD=" - LiveMiniCD"
397
if [ -e /etc/redhat-release.ori ]; then
398
    echo "$( cat /etc/redhat-release.ori )${ADD}" > /etc/redhat-release
1 beyerle@PS 399
fi
400
 
125 beyerle@PS 401
### Set default runlevel to $RUNLEVEL
1 beyerle@PS 402
if [ $RUNLEVEL ]; then
403
    sed -i "s/id:.:initdefault:/id:$RUNLEVEL:initdefault:/" /etc/inittab
404
fi
405
 
125 beyerle@PS 406
### Edit /etc/sysconfig/desktop
1 beyerle@PS 407
if [ $DESKTOP ]; then
408
    sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
409
    echo "DESKTOP=$DESKTOP" >> /etc/sysconfig/desktop
410
fi
411
if [ $DISPLAYMANAGER ]; then
412
    sed -i "/^DISPLAYMANAGER=.*/d" /etc/sysconfig/desktop 2&>/dev/null
413
    echo "DISPLAYMANAGER=$DISPLAYMANAGER" >> /etc/sysconfig/desktop
414
fi
415
 
416
### GDM login background
417
if [ -e /usr/share/gdm/themes/SL/background.png ]; then
418
    cp -a customize/sl${OS_RELEASE}/background.png /usr/share/gdm/themes/SL/background.png
419
fi
420
 
421
### KDE default background
422
if [ ! $PSI ]; then
423
    if [ -e /usr/share/backgrounds/images/default.png ]; then
424
	cp -a customize/sl${OS_RELEASE}/default.png /usr/share/backgrounds/images/default.png
425
    fi
426
fi
427
 
428
### KDE startup/exit sound
429
if [ -e /usr/share/config/knotify.eventsrc ]; then
430
    cp -a customize/sl/knotify.eventsrc /usr/share/config/knotify.eventsrc
431
    cp -a customize/sl/kmixrc /usr/share/config/kmixrc
432
fi
433
 
434
### Configure SELinux
435
if [ $SELINUX ]; then
436
    if [ -e /etc/selinux/config ]; then
437
	sed -i "s|^SELINUX=.*|SELINUX=$SELINUX|" /etc/selinux/config
438
    fi
439
fi
440
 
441
### Do not like jumping CD icon when starting autorun.desktop
442
if [ -e /etc/skel/.kde/Autostart/Autorun.desktop ]; then
443
    grep -q "StartupNotify=false" /etc/skel/.kde/Autostart/Autorun.desktop
444
    if [ "$?" != "0" ]; then
445
	echo "StartupNotify=false" >> /etc/skel/.kde/Autostart/Autorun.desktop
446
    fi
447
fi
448
 
449
echo "done."
450
echo "--------------------------------------------"
451
 
452
 
453
 
454
###############################################################
455
# Add-ons
456
###############################################################
457
 
458
echo "Add-ons ..."
459
 
460
### System icon on desktop
461
if [ -d /usr/share/apps/kdesktop/DesktopLinks ]; then
462
    cp -a customize/System.desktop /usr/share/apps/kdesktop/DesktopLinks/
463
fi
464
 
465
### files for PSI User, will be copied during bootup to /home/$LOCALUSER/
466
if [ $PSI ]; then
467
    rm -rf /usr/share/$LOCALUSER
468
    cp -a customize/$LOCALUSER /usr/share/
469
fi
470
 
471
### psi-menu, psi-scanvirus
472
if [ $PSI ]; then
473
    cp -a customize/psi/psi-menu /usr/bin/
474
    cp -a customize/psi/psi-scanvirus /usr/bin/
475
    [ -d /usr/local/uvscan ] && cp -a customize/psi/update-dat /usr/local/uvscan/
476
    [ -x /usr/bin/freshclam ] && cp -a customize/psi/psi-freshclam /usr/bin/
477
fi
478
 
23 beyerle@PS 479
### script to install LiveCD on local harddisk
31 beyerle@PS 480
cp -a customize/livecd-install  /usr/bin/
16 beyerle@PS 481
 
52 beyerle@PS 482
### GUI for livecd-install
55 beyerle@PS 483
cp -a customize/livecd-install-gui/livecd-install-gui /usr/sbin/
66 beyerle@PS 484
ln -fs consolehelper /usr/bin/livecd-install-gui
55 beyerle@PS 485
cp -a customize/livecd-install-gui/livecd-install-gui.desktop /usr/share/applications/
486
cp -a customize/livecd-install-gui/livecd-install-gui.console.apps /etc/security/console.apps/livecd-install-gui
487
cp -a customize/livecd-install-gui/livecd-install-gui.pam.d /etc/pam.d/livecd-install-gui
52 beyerle@PS 488
 
23 beyerle@PS 489
### livecd-mkinitrd (used by livecd-install)
20 beyerle@PS 490
if [ -e customize/sl${OS_RELEASE}/livecd-mkinitrd ]; then
491
    cp -a customize/sl${OS_RELEASE}/livecd-mkinitrd /usr/sbin/
492
else
493
    cp -a /sbin/mkinitrd /usr/sbin/livecd-mkinitrd
494
fi
495
 
496
 
1 beyerle@PS 497
echo "done."
498
echo "--------------------------------------------"
499
 
500
 
110 beyerle@PS 501
###############################################################
502
# Create missing files
503
###############################################################
1 beyerle@PS 504
 
110 beyerle@PS 505
echo "Create missing files ..."
506
 
1 beyerle@PS 507
###############################################################
110 beyerle@PS 508
# /etc/hosts
509
### copy host file, if not existing
510
[ -e /etc/hosts ] || cp -a customize/hosts /etc/hosts
511
[ -e /etc/sysconfig/networking/profiles/default/hosts ] || cp -a customize/hosts /etc/sysconfig/networking/profiles/default/hosts
512
 
513
 
514
###############################################################
515
# /etc/shadow
115 beyerle@PS 516
if [ ! -e /etc/shadow ]; then
517
    sed -i "s|\*|x|" /etc/passwd
518
    sed -i "s|^root::|root:x:|" /etc/passwd
519
    cat /etc/passwd | cut -d":" -f 1 | while read u; do echo "$u:*:12345:0:99999:1:::"; done >> /etc/shadow
520
    chmod 600 /etc/shadow
521
fi
110 beyerle@PS 522
 
523
# /etc/gshadow
524
if [ ! -e /etc/gshadow ]; then
525
    cp -a /etc/group /etc/gshadow
526
    sed -i "s|:x:|::|"       /etc/gshadow
527
    sed -i "s|:[0-9]\+:|::|" /etc/gshadow
115 beyerle@PS 528
    chmod 600 /etc/gshadow
110 beyerle@PS 529
fi
530
 
531
echo "done."
532
echo "--------------------------------------------"
533
 
534
 
535
 
536
###############################################################
1 beyerle@PS 537
# Create special files
538
###############################################################
539
 
540
echo "Create special files ..."
541
 
542
###############################################################
543
# /etc/rc.d/init.d/kudzu-auto
544
### Noninteractive HW detection and configuration
545
 
128 beyerle@PS 546
cp -a customize/kudzu-auto /etc/rc.d/init.d/kudzu-auto
1 beyerle@PS 547
chmod +x /etc/rc.d/init.d/kudzu-auto
128 beyerle@PS 548
chkconfig --add kudzu-auto
549
chkconfig kudzu-auto on
1 beyerle@PS 550
 
551
 
552
###############################################################
553
# /etc/rc.d/init.d/runveryfirst
554
### Fix some things during bootup - run VERY first
555
# runveryfirst will run at the begining of /etc/rc.d/rc.sysinit
556
 
557
cp -a customize/runveryfirst /etc/init.d/runveryfirst
558
chmod +x /etc/rc.d/init.d/runveryfirst
559
 
560
# execute runveryfirst just before "Initialize hardware"
561
grep -q runveryfirst /etc/rc.d/rc.sysinit
562
if [ "$?" != "0" ]; then
563
    sed -i -e "/^# Initialize hardware/a\/etc\/init.d\/runveryfirst" /etc/rc.d/rc.sysinit
564
fi
565
 
566
 
567
###############################################################
568
# /etc/rc.d/init.d/runfirst
569
### Fix some things during bootup - run first
570
# runfirst will run at the end of /etc/rc.d/rc.sysinit
571
 
572
cp -a customize/runfirst /etc/init.d/runfirst
573
chmod +x /etc/rc.d/init.d/runfirst
574
 
575
sysinit_line="/etc/rc.d/init.d/runfirst"
576
grep -q "$sysinit_line" /etc/rc.d/rc.sysinit
577
if [ "$?" != "0" ]; then
578
    echo "$sysinit_line" >> /etc/rc.d/rc.sysinit
579
    echo >> /etc/rc.d/rc.sysinit
580
fi
581
 
14 beyerle@PS 582
 
1 beyerle@PS 583
###############################################################
584
# /etc/rc.d/init.d/runlast
585
### Fix some things during bootup - run last
586
 
587
cp -a customize/runlast /etc/init.d/runlast
588
chmod +x /etc/rc.d/init.d/runlast
589
 
590
### Add /etc/rc.d/init.d/runlast to rc.local
591
LINE=/etc/rc.d/init.d/runlast
592
grep -q $LINE /etc/rc.d/rc.local
593
if [ "$?" != "0" ]; then
594
    # add line
595
    echo "" >> /etc/rc.d/rc.local
596
    echo $LINE >> /etc/rc.d/rc.local
597
    echo "" >> /etc/rc.d/rc.local    
598
fi
599
 
14 beyerle@PS 600
 
1 beyerle@PS 601
###############################################################
602
# /usr/bin/save-localdata
603
### stores data on a usbstick
604
cp -a customize/save-localdata /usr/bin/save-localdata
605
chmod +x /usr/bin/save-localdata
606
 
607
# add /usr/bin/save-localdata to /etc/sudoers
79 beyerle@PS 608
if [ -e /etc/sudoers ]; then
609
    grep -q "save-localdata" /etc/sudoers 2>/dev/null
610
    if [ "$?" != "0" ]; then
611
	cp -a /etc/sudoers /etc/sudoers.ori
612
	echo "$LOCALUSER ALL = NOPASSWD: /usr/bin/save-localdata" >> /etc/sudoers
613
    fi
1 beyerle@PS 614
fi
615
 
616
# create menu entry
617
cp -a customize/save-localdata.desktop /usr/share/applications/
618
 
14 beyerle@PS 619
 
1 beyerle@PS 620
###############################################################
621
# /usr/bin/set-volume
622
### unmute all mixers and set volumes
623
cp -a customize/set-volume /usr/bin/set-volume
624
chmod +x /usr/bin/set-volume
625
 
14 beyerle@PS 626
 
1 beyerle@PS 627
###############################################################
628
# /etc/sysconfig/networking/devices/ifcfg-eth0
629
# /etc/sysconfig/networking/devices/ifcfg-eth1
630
 
631
for iface in eth0 eth1; do 
632
 
633
    # remove it first
634
    rm -f /etc/sysconfig/networking/devices/ifcfg-${iface} 2>/dev/null
635
    rm -f /etc/sysconfig/networking/profiles/default/ifcfg-${iface} 2>/dev/null
636
    rm -f /etc/sysconfig/network-scripts/ifcfg-${iface} 2>/dev/null
637
 
638
    # create it, if we have a sample
639
    if [ -e customize/sl${OS_RELEASE}/ifcfg-${iface} ]; then
640
	cp -a customize/sl${OS_RELEASE}/ifcfg-${iface} /etc/sysconfig/networking/devices/ifcfg-${iface}
641
        # make hard links
642
	cp -lf /etc/sysconfig/networking/devices/ifcfg-${iface} /etc/sysconfig/networking/profiles/default/
643
	cp -lf /etc/sysconfig/networking/devices/ifcfg-${iface} /etc/sysconfig/network-scripts/
644
    fi
645
done
646
 
647
 
648
###############################################################
649
# /etc/profile.d/setsysfont.sh
650
### setsysfont 
651
cat > /etc/profile.d/setsysfont.sh <<EOF
652
# setsysfont once
653
if [ ! -e /tmp/.sysfont_has_been_set ]; then
654
    touch /tmp/.sysfont_has_been_set
655
    /bin/setfont 2>/dev/null
656
    /sbin/setsysfont 2>/dev/null
657
fi
658
EOF
659
chmod 755 /etc/profile.d/setsysfont.sh
660
 
14 beyerle@PS 661
 
1 beyerle@PS 662
###############################################################
663
# /etc/profile.d/setsysfont.csh
664
### setsysfont 
665
cat > /etc/profile.d/setsysfont.csh <<EOF
666
# setsysfont once
667
if ( ! -e /tmp/.sysfont_has_been_set ) then
668
    touch /tmp/.sysfont_has_been_set
669
    /bin/setfont 2>/dev/null
670
    /sbin/setsysfont 2>/dev/null
671
endif
672
EOF
673
chmod 755 /etc/profile.d/setsysfont.csh
674
 
14 beyerle@PS 675
 
1 beyerle@PS 676
###############################################################
677
# /etc/cron.d/psi
678
### PSI specific cronjobs
679
 
125 beyerle@PS 680
if [ $PSI ] && [ -e customize/psi/cron_psi.sl${OS_RELEASE} ]; then
681
    cp -a customize/psi/cron_psi.sl${OS_RELEASE} /etc/cron.d/psi 
14 beyerle@PS 682
    chmod +x /etc/cron.d/psi
1 beyerle@PS 683
fi
684
 
685
echo "done."
686
echo "--------------------------------------------"
687
 
688
 
689
 
690
###############################################################
691
# Configure services
692
###############################################################
693
 
694
echo "Configure services ..."
695
 
23 beyerle@PS 696
### services off
1 beyerle@PS 697
if [ $PSI ]; then
125 beyerle@PS 698
    chkconfig cfenvd off  2>/dev/null
1 beyerle@PS 699
    chkconfig cfexecd off 2>/dev/null
700
    chkconfig cfservd off 2>/dev/null
701
fi
702
if [ ! "$SERVICES_OFF" = "" ]; then
703
    for service in $SERVICES_OFF; do
704
	chkconfig $service off 2>/dev/null
705
    done
706
fi
125 beyerle@PS 707
 
708
### we do kudzu-auto
1 beyerle@PS 709
chkconfig kudzu off 
710
 
23 beyerle@PS 711
### services on
1 beyerle@PS 712
if [ ! "$SERVICES_ON" = "" ]; then
713
    for service in $SERVICES_ON; do
714
	chkconfig $service on 2>/dev/null
715
    done
716
fi
717
 
718
echo "done."
719
echo "--------------------------------------------"
720
 
721
 
722
###############################################################
723
# Empty files
724
###############################################################
725
 
726
echo "Empty files ..."
727
 
728
### /etc/security/users
729
if [ $PSI ]; then
125 beyerle@PS 730
    rm -f /etc/security/ssh.allow
731
    touch /etc/security/ssh.allow
1 beyerle@PS 732
fi
733
 
734
### Files to empty
735
FILES_TOUCH="/etc/sysconfig/hwconf \
736
             /etc/resolv.conf \
737
             /etc/adjtime \
738
             /etc/modprobe.conf \
739
             /etc/dhclient-eth0.conf"
740
 
741
for file in $FILES_TOUCH; do
742
    rm -rf $file
743
    touch $file
744
done
745
 
746
echo "done."
747
echo "--------------------------------------------"
748
 
749
 
110 beyerle@PS 750
 
1 beyerle@PS 751
###############################################################
752
# Update locate db, prelink, makewhatis
753
###############################################################
754
 
95 beyerle@PS 755
### run updatedb
1 beyerle@PS 756
if [ -x /usr/bin/updatedb ]; then
757
    echo "Run updatedb..."
758
    . /etc/updatedb.conf 2>/dev/null
759
    rpm -q mlocate >/dev/null
760
    if [ "$?" = "0" ]; then
41 beyerle@PS 761
	/usr/bin/updatedb -e "/media /sfs /tmp /boot /livecd /home /net /trunk"
1 beyerle@PS 762
    else
41 beyerle@PS 763
	/usr/bin/updatedb -e /media,/tmp,/boot,/livecd,/home,/net,/trunk
1 beyerle@PS 764
    fi
765
    echo "done."
766
fi
767
 
768
### run prelink
769
if [ -x /etc/cron.daily/prelink ]; then
770
    echo "Run prelink..."
771
    /etc/cron.daily/prelink
772
    echo "done."
773
fi
774
if [ -x /etc/cron_backup/prelink ]; then
775
    echo "Run prelink..."
776
    /etc/cron_backup/prelink
777
    echo "done."
778
fi
23 beyerle@PS 779
 
780
### clean prelink log
1 beyerle@PS 781
rm -f /var/log/prelink/prelink.log 2>/dev/null
782
rm -f /var/log/prelink.log 2>/dev/null
783
 
784
### run makewhatis
125 beyerle@PS 785
which makewhatis >/dev/null 2>&1
786
if [ "$?" = "0" ]; then
1 beyerle@PS 787
    echo "Run makewhatis..."
788
    makewhatis -u -w
789
fi
790
 
791
echo "done."
792
echo "--------------------------------------------"
793
 
794
###############################################################