Subversion Repositories livecd

Rev

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
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
206
rm -f  /root/.ssh/known_hosts
207
rm -rf /root/.subversion
1 beyerle@PS 208
 
209
### clean AFS cache
210
if [ -d /usr/vice/cache ]; then
211
    rm -rf /usr/vice/cache
212
    mkdir /usr/vice/cache
213
fi
214
if [ -d /var/cache/openafs ]; then
215
    rm -rf /var/cache/openafs
216
    mkdir /var/cache/openafs
217
fi
218
 
219
### clean up /var/tmp
220
rm -rf /var/tmp/*
221
 
222
### remove root passwd
223
sed -i "s|^root:.*|root:\*:12943:0:99999:7:::|" /etc/shadow
224
sed -i "s|^root:.*:0:0|root:x:0:0|" /etc/passwd
225
 
226
### remove /.autofsck
23 beyerle@PS 227
rm -f /.autofsck
1 beyerle@PS 228
 
125 beyerle@PS 229
### disable cfagent 
230
[ $PSI ] && mv /etc/cron.d/cfengine      /etc/cron_backup/ 2>/dev/null
1 beyerle@PS 231
 
125 beyerle@PS 232
### disable psi-cronjobs
233
[ $PSI ] && mv /etc/cron.d/psi-cronjobs  /etc/cron_backup/ 2>/dev/null
234
 
235
### disable check_update
23 beyerle@PS 236
[ $PSI ] && sed -i "s|/etc/init.d/check_update|# /etc/init.d/check_update|" /etc/rc.d/rc.local.psi
125 beyerle@PS 237
[ $PSI ] && chkconfig check_update off
1 beyerle@PS 238
 
239
### create in /boot link to LiveCD kernel(s)
240
ln -fs /boot/vmlinuz-$KERNEL /boot/vmlinuz
241
[ $SMP ] && ln -fs /boot/vmlinuz-${KERNEL}smp /boot/vmlinuz${SMP}
242
 
110 beyerle@PS 243
### remove ssh keys
1 beyerle@PS 244
FILES_REMOVE="/etc/ssh/ssh_host_key \
245
              /etc/ssh/ssh_host_key.pub \
246
              /etc/ssh/ssh_host_rsa_key.pub \
247
              /etc/ssh/ssh_host_dsa_key \
248
              /etc/ssh/ssh_host_dsa_key.pub"
249
for file in $FILES_REMOVE; do
23 beyerle@PS 250
    rm -f $file
1 beyerle@PS 251
done
252
 
253
### remove useless cronjobs
254
mkdir -p /etc/cron_backup
125 beyerle@PS 255
mv /etc/cron.d/sysstat                 /etc/cron_backup/ 2>/dev/null
1 beyerle@PS 256
mv /etc/cron.weekly/00-makewhatis.cron /etc/cron_backup/00-makewhatis.cron.weekly 2>/dev/null
125 beyerle@PS 257
mv /etc/cron.daily/00-makewhatis.cron  /etc/cron_backup/ 2>/dev/null
258
mv /etc/cron.daily/makewhatis.cron     /etc/cron_backup/ 2>/dev/null
259
mv /etc/cron.daily/rpm                 /etc/cron_backup/ 2>/dev/null
260
mv /etc/cron.daily/slocate.cron        /etc/cron_backup/ 2>/dev/null
261
mv /etc/cron.daily/tetex.cron          /etc/cron_backup/ 2>/dev/null
262
mv /etc/cron.daily/yum.cron            /etc/cron_backup/ 2>/dev/null
263
mv /etc/cron.daily/prelink             /etc/cron_backup/ 2>/dev/null
1 beyerle@PS 264
 
265
### remove backup of /etc/X11/xorg.conf
125 beyerle@PS 266
rm -f /etc/X11/xorg.conf.ori    2>/dev/null
1 beyerle@PS 267
rm -f /etc/X11/xorg.conf.backup 2>/dev/null
268
 
269
### remove unused dirs in /lib/modules
270
ls /lib/modules/ | grep -v $KERNEL | while read mod_dir; do
271
    rpm -qf --quiet /lib/modules/$mod_dir
272
    if [ $? != "0" ]; then
273
	if [ $mod_dir != "" ]; then
274
	    cleaned_dir=/tmp/cleaned-$( date +%Y%m%d%H%M )
275
	    mkdir -p $cleaned_dir
276
            echo "Move dir /lib/modules/$mod_dir to $cleaned_dir"
277
	    mv -f /lib/modules/$mod_dir $cleaned_dir/
278
        fi
279
    fi
280
done
281
 
282
### move some unneeded files to /mini (not for LiveDVD and miniCD)
110 beyerle@PS 283
#   to save disk space
284
 
1 beyerle@PS 285
if [ ! $DVD ] && [ ! $MINI ]; then
286
 
287
    mkdir -p /mini
288
 
80 beyerle@PS 289
    echo "Move some folders to /mini, to save disk space:"
290
 
1 beyerle@PS 291
    # move some dirs in /usr/share/doc to /mini
292
    mkdir -p /mini/usr/share/doc
115 beyerle@PS 293
    mv -v /usr/share/doc/openafs-*        /mini/usr/share/doc 2>/dev/null
294
    mv -v /usr/share/doc/gcc-*            /mini/usr/share/doc 2>/dev/null
295
    mv -v /usr/share/doc/pine-*           /mini/usr/share/doc 2>/dev/null
296
    mv -v /usr/share/doc/ntp-*            /mini/usr/share/doc 2>/dev/null
297
    mv -v /usr/share/doc/cups-*           /mini/usr/share/doc 2>/dev/null
298
    mv -v /usr/share/doc/testdisk-*       /mini/usr/share/doc 2>/dev/null
299
    mv -v /usr/share/doc/htdig-*          /mini/usr/share/doc 2>/dev/null
300
    mv -v /usr/share/doc/gnome-vfs2-*     /mini/usr/share/doc 2>/dev/null
301
    mv -v /usr/share/doc/bash-*           /mini/usr/share/doc 2>/dev/null
302
    mv -v /usr/share/doc/exim-*           /mini/usr/share/doc 2>/dev/null
80 beyerle@PS 303
    mv -v /usr/share/doc/ghostscript-*    /mini/usr/share/doc 2>/dev/null
304
    mv -v /usr/share/doc/gnuplot-*        /mini/usr/share/doc 2>/dev/null
305
    mv -v /usr/share/doc/ImageMagick-*    /mini/usr/share/doc 2>/dev/null
306
    mv -v /usr/share/doc/isdn4k-utils-*   /mini/usr/share/doc 2>/dev/null
307
    mv -v /usr/share/doc/sane-backends-*  /mini/usr/share/doc 2>/dev/null
117 beyerle@PS 308
 
309
    mkdir -p /mini/usr/share/backgrounds/images
310
    mv -v /usr/share/backgrounds/images/*.gz /mini/usr/share/backgrounds/images/ 2>/dev/null
73 beyerle@PS 311
 
1 beyerle@PS 312
    # move zipped java source to /mini, if j2sdk is installed
313
    java_src=$( rpm -ql j2sdk 2>/dev/null | grep src.zip )
80 beyerle@PS 314
    [ -e "$java_src" ] && mv -v "$java_src" /mini/
315
 
1 beyerle@PS 316
fi
317
 
318
echo "done."
319
echo "--------------------------------------------"
320
 
321
 
322
 
323
###############################################################
324
# Modify files
325
###############################################################
326
 
327
echo "Modify files ..."
328
 
329
### remove AFS startup warning about cache
23 beyerle@PS 330
[ $PSI ] && sed  -i "/\!\!\!/d" /etc/init.d/afs
1 beyerle@PS 331
 
332
### disable umount of loop device during shutdown
333
#   this is done really dirty at the moment:
334
#    -> just replace "loop" with non existing device "lo_fake"
335
 
336
[ -e /etc/init.d/netfs ]     && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/netfs
337
[ -e /etc/init.d/autofs ]    && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/autofs
338
[ -e /etc/init.d/halt ]      && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/halt
339
[ -e /etc/init.d/functions ] && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/functions
340
 
341
# do not shuttdown loopback interface
342
sed -i "s|[^#]action \$\"Shutting down loopback interface:|\t#action \$\"Shutting down loopback interface:|" /etc/init.d/network
343
 
344
### copy new /etc/init.d/halt 
345
cp -a customize/sl${OS_RELEASE}/halt /etc/init.d/halt
346
 
347
### in /etc/rc.d/rc.sysinit
348
#   comment out 'initlog -c "fsck -T -a $rootdev $fsckoptions"' 
349
#   to disable fsck of root filesystem
350
sed -i "s|\tfsck -T -a \$rootdev|\tsleep 0; #fsck -T -a \$rootdev|" /etc/rc.d/rc.sysinit
351
sed -i "s|\tinitlog -c \"fsck -T -a \$rootdev|\tsleep 0; #initlog -c \"fsck -T -a \$rootdev|" /etc/rc.d/rc.sysinit
352
#   disable "Remounting root filesystem in read-write mode"
353
sed -i "s| action \$\"Remounting root filesystem|#action \$\"Remounting root filesystem|" /etc/rc.d/rc.sysinit
354
 
355
### start afs with option -memcache !
356
if [ -e /etc/sysconfig/afs ]; then
357
    if [ $PSI ]; then
358
	sed -i "s|^EXTRA_OPTIONS=.*|EXTRA_OPTIONS='-fakestat -memcache'|" /etc/sysconfig/afs
125 beyerle@PS 359
	sed -i "s|ENABLE_MEMCACHE='no'|ENABLE_MEMCACHE='yes'|" /etc/sysconfig/afs
1 beyerle@PS 360
    else
81 beyerle@PS 361
	# for SL4
1 beyerle@PS 362
	grep -q "\-fakestat \-memcache" /etc/sysconfig/afs
363
	if [ "$?" != "0" ]; then
364
	    sed -i "s|-fakestat|-fakestat -memcache|" /etc/sysconfig/afs
365
	fi
81 beyerle@PS 366
	# for SL5
367
	rpm -q openafs | grep -q SL5
368
	if [ "$?" = "0" ]; then
369
	    sed -i "s|^OPTIONS=.*|OPTIONS=\"-memcache\"|" /etc/sysconfig/afs
370
	fi
1 beyerle@PS 371
    fi
372
fi
373
 
125 beyerle@PS 374
### source /etc/sysconfig/psi
375
[ $PSI ] && . /etc/sysconfig/psi
1 beyerle@PS 376
 
377
### Set /etc/motd
23 beyerle@PS 378
LiveCD="LiveCD"
379
[ "$ARCH" = "x86_64" ] && LiveCD="LiveCD 64bit"
380
echo "Welcome to $LIVECD_OS ${LiveCD}" > /etc/motd
381
[ $PSI ] && echo "Welcome to PSI ${LiveCD} (${CLASS} ${SUBCLASS} SL${RELEASE})" > /etc/motd
68 beyerle@PS 382
[ $DVD ]  && sed -i "s|CD|DVD|"    /etc/motd
383
[ $MINI ] && sed -i "s|CD|MiniCD|" /etc/motd
1 beyerle@PS 384
 
385
### Set hostname to psi or slinux (not really necessary)
386
if [ $PSI ]; then
387
    HOSTNAME="psi"
388
    sed -i "s/hostname=.*/hostname=${HOSTNAME}.psi.ch/" /etc/ssmtp/ssmtp.conf
125 beyerle@PS 389
    sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/psi
1 beyerle@PS 390
else
23 beyerle@PS 391
    HOSTNAME="$DEFAULT_HOSTNAME"
392
fi
1 beyerle@PS 393
 
125 beyerle@PS 394
### Change hostname
1 beyerle@PS 395
sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/network
396
sed -i "s/DHCP_HOSTNAME=.*/DHCP_HOSTNAME==${HOSTNAME}/" /etc/sysconfig/networking/devices/ifcfg-eth0 2>/dev/null
397
 
398
### Modify /etc/redhat-release
93 beyerle@PS 399
ADD=" - LiveCD"
400
[ $DVD ]  && ADD=" - LiveDVD"
401
[ $MINI ] && ADD=" - LiveMiniCD"
402
if [ -e /etc/redhat-release.ori ]; then
403
    echo "$( cat /etc/redhat-release.ori )${ADD}" > /etc/redhat-release
1 beyerle@PS 404
fi
405
 
125 beyerle@PS 406
### Set default runlevel to $RUNLEVEL
1 beyerle@PS 407
if [ $RUNLEVEL ]; then
408
    sed -i "s/id:.:initdefault:/id:$RUNLEVEL:initdefault:/" /etc/inittab
409
fi
410
 
125 beyerle@PS 411
### Edit /etc/sysconfig/desktop
1 beyerle@PS 412
if [ $DESKTOP ]; then
413
    sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
414
    echo "DESKTOP=$DESKTOP" >> /etc/sysconfig/desktop
415
fi
416
if [ $DISPLAYMANAGER ]; then
417
    sed -i "/^DISPLAYMANAGER=.*/d" /etc/sysconfig/desktop 2&>/dev/null
418
    echo "DISPLAYMANAGER=$DISPLAYMANAGER" >> /etc/sysconfig/desktop
419
fi
420
 
421
### GDM login background
422
if [ -e /usr/share/gdm/themes/SL/background.png ]; then
423
    cp -a customize/sl${OS_RELEASE}/background.png /usr/share/gdm/themes/SL/background.png
424
fi
425
 
426
### KDE default background
427
if [ ! $PSI ]; then
428
    if [ -e /usr/share/backgrounds/images/default.png ]; then
429
	cp -a customize/sl${OS_RELEASE}/default.png /usr/share/backgrounds/images/default.png
430
    fi
431
fi
432
 
433
### KDE startup/exit sound
434
if [ -e /usr/share/config/knotify.eventsrc ]; then
435
    cp -a customize/sl/knotify.eventsrc /usr/share/config/knotify.eventsrc
436
    cp -a customize/sl/kmixrc /usr/share/config/kmixrc
437
fi
438
 
439
### Configure SELinux
440
if [ $SELINUX ]; then
441
    if [ -e /etc/selinux/config ]; then
442
	sed -i "s|^SELINUX=.*|SELINUX=$SELINUX|" /etc/selinux/config
443
    fi
444
fi
445
 
446
### Do not like jumping CD icon when starting autorun.desktop
447
if [ -e /etc/skel/.kde/Autostart/Autorun.desktop ]; then
448
    grep -q "StartupNotify=false" /etc/skel/.kde/Autostart/Autorun.desktop
449
    if [ "$?" != "0" ]; then
450
	echo "StartupNotify=false" >> /etc/skel/.kde/Autostart/Autorun.desktop
451
    fi
452
fi
453
 
454
echo "done."
455
echo "--------------------------------------------"
456
 
457
 
458
 
459
###############################################################
460
# Add-ons
461
###############################################################
462
 
463
echo "Add-ons ..."
464
 
465
### System icon on desktop
466
if [ -d /usr/share/apps/kdesktop/DesktopLinks ]; then
467
    cp -a customize/System.desktop /usr/share/apps/kdesktop/DesktopLinks/
468
fi
469
 
470
### files for PSI User, will be copied during bootup to /home/$LOCALUSER/
471
if [ $PSI ]; then
472
    rm -rf /usr/share/$LOCALUSER
473
    cp -a customize/$LOCALUSER /usr/share/
474
fi
475
 
476
### psi-menu, psi-scanvirus
477
if [ $PSI ]; then
478
    cp -a customize/psi/psi-menu /usr/bin/
479
    cp -a customize/psi/psi-scanvirus /usr/bin/
480
    [ -d /usr/local/uvscan ] && cp -a customize/psi/update-dat /usr/local/uvscan/
481
    [ -x /usr/bin/freshclam ] && cp -a customize/psi/psi-freshclam /usr/bin/
482
fi
483
 
23 beyerle@PS 484
### script to install LiveCD on local harddisk
31 beyerle@PS 485
cp -a customize/livecd-install  /usr/bin/
16 beyerle@PS 486
 
52 beyerle@PS 487
### GUI for livecd-install
55 beyerle@PS 488
cp -a customize/livecd-install-gui/livecd-install-gui /usr/sbin/
66 beyerle@PS 489
ln -fs consolehelper /usr/bin/livecd-install-gui
55 beyerle@PS 490
cp -a customize/livecd-install-gui/livecd-install-gui.desktop /usr/share/applications/
491
cp -a customize/livecd-install-gui/livecd-install-gui.console.apps /etc/security/console.apps/livecd-install-gui
492
cp -a customize/livecd-install-gui/livecd-install-gui.pam.d /etc/pam.d/livecd-install-gui
52 beyerle@PS 493
 
23 beyerle@PS 494
### livecd-mkinitrd (used by livecd-install)
20 beyerle@PS 495
if [ -e customize/sl${OS_RELEASE}/livecd-mkinitrd ]; then
496
    cp -a customize/sl${OS_RELEASE}/livecd-mkinitrd /usr/sbin/
497
else
498
    cp -a /sbin/mkinitrd /usr/sbin/livecd-mkinitrd
499
fi
500
 
501
 
1 beyerle@PS 502
echo "done."
503
echo "--------------------------------------------"
504
 
505
 
110 beyerle@PS 506
###############################################################
507
# Create missing files
508
###############################################################
1 beyerle@PS 509
 
110 beyerle@PS 510
echo "Create missing files ..."
511
 
1 beyerle@PS 512
###############################################################
110 beyerle@PS 513
# /etc/hosts
514
### copy host file, if not existing
515
[ -e /etc/hosts ] || cp -a customize/hosts /etc/hosts
516
[ -e /etc/sysconfig/networking/profiles/default/hosts ] || cp -a customize/hosts /etc/sysconfig/networking/profiles/default/hosts
517
 
518
 
519
###############################################################
520
# /etc/shadow
115 beyerle@PS 521
if [ ! -e /etc/shadow ]; then
522
    sed -i "s|\*|x|" /etc/passwd
523
    sed -i "s|^root::|root:x:|" /etc/passwd
524
    cat /etc/passwd | cut -d":" -f 1 | while read u; do echo "$u:*:12345:0:99999:1:::"; done >> /etc/shadow
525
    chmod 600 /etc/shadow
526
fi
110 beyerle@PS 527
 
528
# /etc/gshadow
529
if [ ! -e /etc/gshadow ]; then
530
    cp -a /etc/group /etc/gshadow
531
    sed -i "s|:x:|::|"       /etc/gshadow
532
    sed -i "s|:[0-9]\+:|::|" /etc/gshadow
115 beyerle@PS 533
    chmod 600 /etc/gshadow
110 beyerle@PS 534
fi
535
 
536
echo "done."
537
echo "--------------------------------------------"
538
 
539
 
540
 
541
###############################################################
1 beyerle@PS 542
# Create special files
543
###############################################################
544
 
545
echo "Create special files ..."
546
 
547
###############################################################
548
# /etc/rc.d/init.d/kudzu-auto
549
### Noninteractive HW detection and configuration
550
 
128 beyerle@PS 551
cp -a customize/kudzu-auto /etc/rc.d/init.d/kudzu-auto
1 beyerle@PS 552
chmod +x /etc/rc.d/init.d/kudzu-auto
128 beyerle@PS 553
chkconfig --add kudzu-auto
554
chkconfig kudzu-auto on
1 beyerle@PS 555
 
556
 
557
###############################################################
558
# /etc/rc.d/init.d/runveryfirst
559
### Fix some things during bootup - run VERY first
560
# runveryfirst will run at the begining of /etc/rc.d/rc.sysinit
561
 
562
cp -a customize/runveryfirst /etc/init.d/runveryfirst
563
chmod +x /etc/rc.d/init.d/runveryfirst
564
 
565
# execute runveryfirst just before "Initialize hardware"
566
grep -q runveryfirst /etc/rc.d/rc.sysinit
567
if [ "$?" != "0" ]; then
568
    sed -i -e "/^# Initialize hardware/a\/etc\/init.d\/runveryfirst" /etc/rc.d/rc.sysinit
569
fi
570
 
571
 
572
###############################################################
573
# /etc/rc.d/init.d/runfirst
574
### Fix some things during bootup - run first
575
# runfirst will run at the end of /etc/rc.d/rc.sysinit
576
 
577
cp -a customize/runfirst /etc/init.d/runfirst
578
chmod +x /etc/rc.d/init.d/runfirst
579
 
580
sysinit_line="/etc/rc.d/init.d/runfirst"
581
grep -q "$sysinit_line" /etc/rc.d/rc.sysinit
582
if [ "$?" != "0" ]; then
583
    echo "$sysinit_line" >> /etc/rc.d/rc.sysinit
584
    echo >> /etc/rc.d/rc.sysinit
585
fi
586
 
14 beyerle@PS 587
 
1 beyerle@PS 588
###############################################################
589
# /etc/rc.d/init.d/runlast
590
### Fix some things during bootup - run last
591
 
592
cp -a customize/runlast /etc/init.d/runlast
593
chmod +x /etc/rc.d/init.d/runlast
594
 
595
### Add /etc/rc.d/init.d/runlast to rc.local
596
LINE=/etc/rc.d/init.d/runlast
597
grep -q $LINE /etc/rc.d/rc.local
598
if [ "$?" != "0" ]; then
599
    # add line
600
    echo "" >> /etc/rc.d/rc.local
601
    echo $LINE >> /etc/rc.d/rc.local
602
    echo "" >> /etc/rc.d/rc.local    
603
fi
604
 
14 beyerle@PS 605
 
1 beyerle@PS 606
###############################################################
607
# /usr/bin/save-localdata
608
### stores data on a usbstick
609
cp -a customize/save-localdata /usr/bin/save-localdata
610
chmod +x /usr/bin/save-localdata
611
 
612
# add /usr/bin/save-localdata to /etc/sudoers
79 beyerle@PS 613
if [ -e /etc/sudoers ]; then
614
    grep -q "save-localdata" /etc/sudoers 2>/dev/null
615
    if [ "$?" != "0" ]; then
616
	cp -a /etc/sudoers /etc/sudoers.ori
617
	echo "$LOCALUSER ALL = NOPASSWD: /usr/bin/save-localdata" >> /etc/sudoers
618
    fi
1 beyerle@PS 619
fi
620
 
621
# create menu entry
622
cp -a customize/save-localdata.desktop /usr/share/applications/
623
 
14 beyerle@PS 624
 
1 beyerle@PS 625
###############################################################
626
# /usr/bin/set-volume
627
### unmute all mixers and set volumes
628
cp -a customize/set-volume /usr/bin/set-volume
629
chmod +x /usr/bin/set-volume
630
 
14 beyerle@PS 631
 
1 beyerle@PS 632
###############################################################
633
# /etc/sysconfig/networking/devices/ifcfg-eth0
634
# /etc/sysconfig/networking/devices/ifcfg-eth1
635
 
636
for iface in eth0 eth1; do 
637
 
638
    # remove it first
639
    rm -f /etc/sysconfig/networking/devices/ifcfg-${iface} 2>/dev/null
640
    rm -f /etc/sysconfig/networking/profiles/default/ifcfg-${iface} 2>/dev/null
641
    rm -f /etc/sysconfig/network-scripts/ifcfg-${iface} 2>/dev/null
642
 
643
    # create it, if we have a sample
644
    if [ -e customize/sl${OS_RELEASE}/ifcfg-${iface} ]; then
645
	cp -a customize/sl${OS_RELEASE}/ifcfg-${iface} /etc/sysconfig/networking/devices/ifcfg-${iface}
646
        # make hard links
647
	cp -lf /etc/sysconfig/networking/devices/ifcfg-${iface} /etc/sysconfig/networking/profiles/default/
648
	cp -lf /etc/sysconfig/networking/devices/ifcfg-${iface} /etc/sysconfig/network-scripts/
649
    fi
650
done
651
 
652
 
653
###############################################################
654
# /etc/profile.d/setsysfont.sh
655
### setsysfont 
656
cat > /etc/profile.d/setsysfont.sh <<EOF
657
# setsysfont once
658
if [ ! -e /tmp/.sysfont_has_been_set ]; then
659
    touch /tmp/.sysfont_has_been_set
660
    /bin/setfont 2>/dev/null
661
    /sbin/setsysfont 2>/dev/null
662
fi
663
EOF
664
chmod 755 /etc/profile.d/setsysfont.sh
665
 
14 beyerle@PS 666
 
1 beyerle@PS 667
###############################################################
668
# /etc/profile.d/setsysfont.csh
669
### setsysfont 
670
cat > /etc/profile.d/setsysfont.csh <<EOF
671
# setsysfont once
672
if ( ! -e /tmp/.sysfont_has_been_set ) then
673
    touch /tmp/.sysfont_has_been_set
674
    /bin/setfont 2>/dev/null
675
    /sbin/setsysfont 2>/dev/null
676
endif
677
EOF
678
chmod 755 /etc/profile.d/setsysfont.csh
679
 
14 beyerle@PS 680
 
1 beyerle@PS 681
###############################################################
682
# /etc/cron.d/psi
683
### PSI specific cronjobs
684
 
125 beyerle@PS 685
if [ $PSI ] && [ -e customize/psi/cron_psi.sl${OS_RELEASE} ]; then
686
    cp -a customize/psi/cron_psi.sl${OS_RELEASE} /etc/cron.d/psi 
14 beyerle@PS 687
    chmod +x /etc/cron.d/psi
1 beyerle@PS 688
fi
689
 
690
echo "done."
691
echo "--------------------------------------------"
692
 
693
 
694
 
695
###############################################################
696
# Configure services
697
###############################################################
698
 
699
echo "Configure services ..."
700
 
23 beyerle@PS 701
### services off
1 beyerle@PS 702
if [ $PSI ]; then
125 beyerle@PS 703
    chkconfig cfenvd off  2>/dev/null
1 beyerle@PS 704
    chkconfig cfexecd off 2>/dev/null
705
    chkconfig cfservd off 2>/dev/null
706
fi
707
if [ ! "$SERVICES_OFF" = "" ]; then
708
    for service in $SERVICES_OFF; do
709
	chkconfig $service off 2>/dev/null
710
    done
711
fi
125 beyerle@PS 712
 
713
### we do kudzu-auto
1 beyerle@PS 714
chkconfig kudzu off 
715
 
23 beyerle@PS 716
### services on
1 beyerle@PS 717
if [ ! "$SERVICES_ON" = "" ]; then
718
    for service in $SERVICES_ON; do
719
	chkconfig $service on 2>/dev/null
720
    done
721
fi
722
 
723
echo "done."
724
echo "--------------------------------------------"
725
 
726
 
727
###############################################################
728
# Empty files
729
###############################################################
730
 
731
echo "Empty files ..."
732
 
733
### /etc/security/users
734
if [ $PSI ]; then
125 beyerle@PS 735
    rm -f /etc/security/ssh.allow
736
    touch /etc/security/ssh.allow
1 beyerle@PS 737
fi
738
 
739
### Files to empty
740
FILES_TOUCH="/etc/sysconfig/hwconf \
741
             /etc/resolv.conf \
742
             /etc/adjtime \
743
             /etc/modprobe.conf \
744
             /etc/dhclient-eth0.conf"
745
 
746
for file in $FILES_TOUCH; do
747
    rm -rf $file
748
    touch $file
749
done
750
 
751
echo "done."
752
echo "--------------------------------------------"
753
 
754
 
110 beyerle@PS 755
 
1 beyerle@PS 756
###############################################################
757
# Update locate db, prelink, makewhatis
758
###############################################################
759
 
95 beyerle@PS 760
### run updatedb
1 beyerle@PS 761
if [ -x /usr/bin/updatedb ]; then
762
    echo "Run updatedb..."
763
    . /etc/updatedb.conf 2>/dev/null
764
    rpm -q mlocate >/dev/null
765
    if [ "$?" = "0" ]; then
41 beyerle@PS 766
	/usr/bin/updatedb -e "/media /sfs /tmp /boot /livecd /home /net /trunk"
1 beyerle@PS 767
    else
41 beyerle@PS 768
	/usr/bin/updatedb -e /media,/tmp,/boot,/livecd,/home,/net,/trunk
1 beyerle@PS 769
    fi
770
    echo "done."
771
fi
772
 
773
### run prelink
774
if [ -x /etc/cron.daily/prelink ]; then
775
    echo "Run prelink..."
776
    /etc/cron.daily/prelink
777
    echo "done."
778
fi
779
if [ -x /etc/cron_backup/prelink ]; then
780
    echo "Run prelink..."
781
    /etc/cron_backup/prelink
782
    echo "done."
783
fi
23 beyerle@PS 784
 
785
### clean prelink log
1 beyerle@PS 786
rm -f /var/log/prelink/prelink.log 2>/dev/null
787
rm -f /var/log/prelink.log 2>/dev/null
788
 
789
### run makewhatis
125 beyerle@PS 790
which makewhatis >/dev/null 2>&1
791
if [ "$?" = "0" ]; then
1 beyerle@PS 792
    echo "Run makewhatis..."
793
    makewhatis -u -w
794
fi
795
 
796
echo "done."
797
echo "--------------------------------------------"
798
 
799
###############################################################