Subversion Repositories livecd

Rev

Rev 95 | Rev 110 | 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
 
101
# build nvidia kernel modules
23 beyerle@PS 102
[ -x /usr/sbin/mknvidia ] && mknvidia
1 beyerle@PS 103
 
104
# build vpnclient kernel module
23 beyerle@PS 105
[ -x /usr/sbin/mkvpnclient ] && mkvpnclient
1 beyerle@PS 106
 
107
# Update Virus definitions 
108
# run freshclam
109
if [ -x /usr/bin/freshclam ]; then
110
    echo; echo "Run /usr/bin/freshclam:"
111
    /etc/init.d/clamd status || /etc/init.d/clamd start && /usr/bin/freshclam
112
    /etc/init.d/clamd stop
113
    echo
114
fi
115
# update f-prot and uvscan
116
[ -x /usr/local/f-prot/tools/check-updates.pl ] && /usr/local/f-prot/tools/check-updates.pl
117
[ -x /usr/local/uvscan/update-dat ] && /usr/local/uvscan/update-dat
118
 
119
# run depmod -a for the LiveCD kernels
120
echo "Run depmod -a $KERNEL ..."; depmod -a $KERNEL
121
if [ $SMP ]; then
122
    echo "Run depmod -a ${KERNEL}smp ..."
123
    depmod -a ${KERNEL}smp
124
fi
125
 
126
# delete users (just to be sure)
127
userdel -r $LOCALUSER 2>/dev/null
128
userdel -r l_psi 2>/dev/null
129
userdel -r sluser 2>/dev/null
130
userdel -r user 2>/dev/null
131
 
132
# move /opt to /usr/opt and link /opt -> /usr/opt
133
# (if not already yet done before)
101 beyerle@PS 134
# if [ ! -L /opt ]; then
135
#    echo "Move /opt to /usr/opt"
136
#    mv /opt /usr/
137
#    ln -s /usr/opt /opt
138
# fi
139
# 
140
# fix /opt link (can be removed later)
141
if [ -L /opt ]; then
142
    echo "Move /usr/opt back to /opt"
143
    rm -f /opt
144
    mv /usr/opt /opt
1 beyerle@PS 145
fi
146
 
147
# umount PSI master
23 beyerle@PS 148
[ $PSI ] && umount /mnt/master 2>/dev/null
1 beyerle@PS 149
 
150
# copy back /etc/yum.repos.d
151
if [ ! $PSI ]; then
152
    if [ -d /etc/yum.repos.d.ori ]; then
153
	cp -a /etc/yum.repos.d.ori /etc/yum.repos.d
154
    fi
155
fi
156
 
157
# run cfagent
158
if [ $PSI ]; then
159
    # cfagent needs running afs
160
    /etc/init.d/afs start
161
    echo "Run cfagent ..."
162
    cfagent
163
fi
164
 
165
echo "done."
166
echo "--------------------------------------------"
167
 
168
 
169
 
170
###############################################################
171
# Clean up and delete files
172
###############################################################
173
 
174
echo "Cleaning up ..."
175
 
176
### set LANG
177
export LANG=C
178
 
179
### stop AFS
180
/etc/init.d/afs stop 2>/dev/null
181
 
182
### clean up yum
183
yum clean all >/dev/null
184
rm -rf /var/cache/yum/*
185
 
186
### remove cfengine log files
187
rm -f /var/cfengine/*log
188
 
189
### delete log files
190
find /var/log/ -type f -exec rm -f {} \;
191
 
192
### clean rpm database
193
rm -rf /var/lib/rpm/__db.*
194
 
195
### clean /var/spool/mail
196
rm -rf /var/spool/mail/*
197
touch /var/spool/mail/root
198
chmod 600 /var/spool/mail/root
199
 
200
### delete .cfsaved Files
201
if [ $PSI ]; then
202
    echo -n "Delete .cfsaved Files, please wait: "
203
    find / -xdev -name "*\.cfsaved" -exec rm -f {} \;
204
    echo "ok."
205
fi
206
 
207
### delete .rpmori .rpm Files in /etc
208
find /etc -name "*\.rpmorig" -exec rm -f {} \;
209
find /etc -name "*\.rpmnew"  -exec rm -f {} \;
29 beyerle@PS 210
find /etc -name "*\.rpmsave" -exec rm -f {} \;
1 beyerle@PS 211
 
212
### delete *~ files in /etc
213
find /etc | grep "~$" | while read f; do rm -f "$f"; done
214
 
215
### clean up /root
56 beyerle@PS 216
rm -f  /root/.bash_history
217
rm -f  /root/.ssh/known_hosts
218
rm -rf /root/.subversion
1 beyerle@PS 219
 
220
### clean AFS cache
221
if [ -d /usr/vice/cache ]; then
222
    rm -rf /usr/vice/cache
223
    mkdir /usr/vice/cache
224
fi
225
if [ -d /var/cache/openafs ]; then
226
    rm -rf /var/cache/openafs
227
    mkdir /var/cache/openafs
228
fi
229
 
230
### clean up /var/tmp
231
rm -rf /var/tmp/*
232
 
233
### remove root passwd
234
sed -i "s|^root:.*|root:\*:12943:0:99999:7:::|" /etc/shadow
235
sed -i "s|^root:.*:0:0|root:x:0:0|" /etc/passwd
236
 
237
### remove /.autofsck
23 beyerle@PS 238
rm -f /.autofsck
1 beyerle@PS 239
 
240
### disable cfagent
241
rm -f /etc/cron.d/cfengine
242
 
243
### disable check_update in rc.local.psi
23 beyerle@PS 244
[ $PSI ] && sed -i "s|/etc/init.d/check_update|# /etc/init.d/check_update|" /etc/rc.d/rc.local.psi
1 beyerle@PS 245
 
246
### create in /boot link to LiveCD kernel(s)
247
ln -fs /boot/vmlinuz-$KERNEL /boot/vmlinuz
248
[ $SMP ] && ln -fs /boot/vmlinuz-${KERNEL}smp /boot/vmlinuz${SMP}
249
 
250
### Files to remove
251
FILES_REMOVE="/etc/ssh/ssh_host_key \
252
              /etc/ssh/ssh_host_key.pub \
253
              /etc/ssh/ssh_host_rsa_key.pub \
254
              /etc/ssh/ssh_host_dsa_key \
255
              /etc/ssh/ssh_host_dsa_key.pub"
256
for file in $FILES_REMOVE; do
23 beyerle@PS 257
    rm -f $file
1 beyerle@PS 258
done
259
 
260
### remove useless cronjobs
261
mkdir -p /etc/cron_backup
262
mv /etc/cron.d/sysstat /etc/cron_backup/ 2>/dev/null
263
mv /etc/cron.daily/00-makewhatis.cron /etc/cron_backup/ 2>/dev/null
264
mv /etc/cron.weekly/00-makewhatis.cron /etc/cron_backup/00-makewhatis.cron.weekly 2>/dev/null
265
mv /etc/cron.daily/rpm /etc/cron_backup/ 2>/dev/null
266
mv /etc/cron.daily/slocate.cron /etc/cron_backup/ 2>/dev/null
267
mv /etc/cron.daily/tetex.cron /etc/cron_backup/ 2>/dev/null
268
mv /etc/cron.daily/yum.cron /etc/cron_backup/ 2>/dev/null
269
mv /etc/cron.daily/prelink /etc/cron_backup/ 2>/dev/null
270
mv /etc/cron.daily/00-logwatch /etc/cron_backup/ 2>/dev/null
271
 
272
### remove desktop entry from crossover
23 beyerle@PS 273
[ $PSI ] && rm -f "/usr/share/apps/kdesktop/DesktopLinks/Internet Explorer.desktop"
1 beyerle@PS 274
 
275
### remove backup of /etc/X11/xorg.conf
276
rm -f /etc/X11/xorg.conf.ori 2>/dev/null
277
rm -f /etc/X11/xorg.conf.backup 2>/dev/null
278
 
279
### remove unused dirs in /lib/modules
280
ls /lib/modules/ | grep -v $KERNEL | while read mod_dir; do
281
    rpm -qf --quiet /lib/modules/$mod_dir
282
    if [ $? != "0" ]; then
283
	if [ $mod_dir != "" ]; then
284
	    cleaned_dir=/tmp/cleaned-$( date +%Y%m%d%H%M )
285
	    mkdir -p $cleaned_dir
286
            echo "Move dir /lib/modules/$mod_dir to $cleaned_dir"
287
	    mv -f /lib/modules/$mod_dir $cleaned_dir/
288
        fi
289
    fi
290
done
291
 
292
### move some unneeded files to /mini (not for LiveDVD and miniCD)
293
if [ ! $DVD ] && [ ! $MINI ]; then
294
    # to save disk space
295
 
296
    mkdir -p /mini
297
 
80 beyerle@PS 298
    echo "Move some folders to /mini, to save disk space:"
299
 
1 beyerle@PS 300
    # move some dirs in /usr/share/doc to /mini
301
    mkdir -p /mini/usr/share/doc
80 beyerle@PS 302
    mv -v /usr/share/doc/openafs-*    /mini/usr/share/doc 2>/dev/null
303
    mv -v /usr/share/doc/gcc-*        /mini/usr/share/doc 2>/dev/null
304
    mv -v /usr/share/doc/pine-*       /mini/usr/share/doc 2>/dev/null
305
    mv -v /usr/share/doc/ntp-*        /mini/usr/share/doc 2>/dev/null
306
    mv -v /usr/share/doc/cups-*       /mini/usr/share/doc 2>/dev/null
307
    mv -v /usr/share/doc/testdisk-*   /mini/usr/share/doc 2>/dev/null
308
    mv -v /usr/share/doc/htdig-*      /mini/usr/share/doc 2>/dev/null
309
    mv -v /usr/share/doc/gnome-vfs2-* /mini/usr/share/doc 2>/dev/null
310
    mv -v /usr/share/doc/bash-*       /mini/usr/share/doc 2>/dev/null
311
    mv -v /usr/share/doc/exim-*       /mini/usr/share/doc 2>/dev/null
312
    mv -v /usr/share/doc/ghostscript-*    /mini/usr/share/doc 2>/dev/null
313
    mv -v /usr/share/doc/gnuplot-*        /mini/usr/share/doc 2>/dev/null
314
    mv -v /usr/share/doc/ImageMagick-*    /mini/usr/share/doc 2>/dev/null
315
    mv -v /usr/share/doc/isdn4k-utils-*   /mini/usr/share/doc 2>/dev/null
316
    mv -v /usr/share/doc/sane-backends-*  /mini/usr/share/doc 2>/dev/null
73 beyerle@PS 317
 
1 beyerle@PS 318
    # move zipped java source to /mini, if j2sdk is installed
319
    java_src=$( rpm -ql j2sdk 2>/dev/null | grep src.zip )
80 beyerle@PS 320
    [ -e "$java_src" ] && mv -v "$java_src" /mini/
321
 
1 beyerle@PS 322
fi
323
 
33 beyerle@PS 324
### remove /etc/rc.d/init.d/login (should only be on Mini LiveCD)
325
##  this will be obsolete soon.
326
rm -f /etc/rc.d/init.d/login
327
 
328
 
1 beyerle@PS 329
echo "done."
330
echo "--------------------------------------------"
331
 
332
 
333
 
334
###############################################################
335
# Modify files
336
###############################################################
337
 
338
echo "Modify files ..."
339
 
340
### remove AFS startup warning about cache
23 beyerle@PS 341
[ $PSI ] && sed  -i "/\!\!\!/d" /etc/init.d/afs
1 beyerle@PS 342
 
343
### disable umount of loop device during shutdown
344
#   this is done really dirty at the moment:
345
#    -> just replace "loop" with non existing device "lo_fake"
346
 
347
[ -e /etc/init.d/netfs ]     && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/netfs
348
[ -e /etc/init.d/autofs ]    && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/autofs
349
[ -e /etc/init.d/halt ]      && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/halt
350
[ -e /etc/init.d/functions ] && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/functions
351
 
352
# do not shuttdown loopback interface
353
sed -i "s|[^#]action \$\"Shutting down loopback interface:|\t#action \$\"Shutting down loopback interface:|" /etc/init.d/network
354
 
355
### copy new /etc/init.d/halt 
356
cp -a customize/sl${OS_RELEASE}/halt /etc/init.d/halt
357
 
358
### in /etc/rc.d/rc.sysinit
359
#   comment out 'initlog -c "fsck -T -a $rootdev $fsckoptions"' 
360
#   to disable fsck of root filesystem
361
sed -i "s|\tfsck -T -a \$rootdev|\tsleep 0; #fsck -T -a \$rootdev|" /etc/rc.d/rc.sysinit
362
sed -i "s|\tinitlog -c \"fsck -T -a \$rootdev|\tsleep 0; #initlog -c \"fsck -T -a \$rootdev|" /etc/rc.d/rc.sysinit
363
#   disable "Remounting root filesystem in read-write mode"
364
sed -i "s| action \$\"Remounting root filesystem|#action \$\"Remounting root filesystem|" /etc/rc.d/rc.sysinit
365
 
366
### start afs with option -memcache !
367
if [ -e /etc/sysconfig/afs ]; then
368
    if [ $PSI ]; then
369
	sed -i "s|^EXTRA_OPTIONS=.*|EXTRA_OPTIONS='-fakestat -memcache'|" /etc/sysconfig/afs
370
    else
81 beyerle@PS 371
	# for SL4
1 beyerle@PS 372
	grep -q "\-fakestat \-memcache" /etc/sysconfig/afs
373
	if [ "$?" != "0" ]; then
374
	    sed -i "s|-fakestat|-fakestat -memcache|" /etc/sysconfig/afs
375
	fi
81 beyerle@PS 376
	# for SL5
377
	rpm -q openafs | grep -q SL5
378
	if [ "$?" = "0" ]; then
379
	    sed -i "s|^OPTIONS=.*|OPTIONS=\"-memcache\"|" /etc/sysconfig/afs
380
	fi
1 beyerle@PS 381
    fi
382
fi
383
 
384
### source /etc/sysconfig/cfengine
385
[ $PSI ] && . /etc/sysconfig/cfengine
386
 
387
### Set /etc/motd
23 beyerle@PS 388
LiveCD="LiveCD"
389
[ "$ARCH" = "x86_64" ] && LiveCD="LiveCD 64bit"
390
echo "Welcome to $LIVECD_OS ${LiveCD}" > /etc/motd
391
[ $PSI ] && echo "Welcome to PSI ${LiveCD} (${CLASS} ${SUBCLASS} SL${RELEASE})" > /etc/motd
68 beyerle@PS 392
[ $DVD ]  && sed -i "s|CD|DVD|"    /etc/motd
393
[ $MINI ] && sed -i "s|CD|MiniCD|" /etc/motd
1 beyerle@PS 394
 
395
### Set hostname to psi or slinux (not really necessary)
396
if [ $PSI ]; then
397
    HOSTNAME="psi"
398
    sed -i "s/hostname=.*/hostname=${HOSTNAME}.psi.ch/" /etc/ssmtp/ssmtp.conf
399
    sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/cfengine
400
else
23 beyerle@PS 401
    HOSTNAME="$DEFAULT_HOSTNAME"
402
fi
1 beyerle@PS 403
 
404
# change hostname
405
sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/network
406
sed -i "s/DHCP_HOSTNAME=.*/DHCP_HOSTNAME==${HOSTNAME}/" /etc/sysconfig/networking/devices/ifcfg-eth0 2>/dev/null
407
 
408
### Modify /etc/redhat-release
93 beyerle@PS 409
ADD=" - LiveCD"
410
[ $DVD ]  && ADD=" - LiveDVD"
411
[ $MINI ] && ADD=" - LiveMiniCD"
412
if [ -e /etc/redhat-release.ori ]; then
413
    echo "$( cat /etc/redhat-release.ori )${ADD}" > /etc/redhat-release
1 beyerle@PS 414
fi
415
 
416
### Make scratch
417
if [ $PSI ]; then
418
    rm -rf /home/scratch
419
    mkdir -p /home/scratch
420
    chmod 1777 /home/scratch
421
    rm -rf /scratch
422
    ln -s /home/scratch /scratch
423
else
424
    rm -rf /home/scratch
425
    rm -rf /scratch
426
    mkdir -p /scratch
427
    chmod 1777 /scratch
428
fi
429
 
430
### set default runlevel to $RUNLEVEL
431
if [ $RUNLEVEL ]; then
432
    sed -i "s/id:.:initdefault:/id:$RUNLEVEL:initdefault:/" /etc/inittab
433
fi
434
 
435
### edit /etc/sysconfig/desktop
436
if [ $DESKTOP ]; then
437
    sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
438
    echo "DESKTOP=$DESKTOP" >> /etc/sysconfig/desktop
439
fi
440
if [ $DISPLAYMANAGER ]; then
441
    sed -i "/^DISPLAYMANAGER=.*/d" /etc/sysconfig/desktop 2&>/dev/null
442
    echo "DISPLAYMANAGER=$DISPLAYMANAGER" >> /etc/sysconfig/desktop
443
fi
444
 
445
### GDM login background
446
if [ -e /usr/share/gdm/themes/SL/background.png ]; then
447
    cp -a customize/sl${OS_RELEASE}/background.png /usr/share/gdm/themes/SL/background.png
448
fi
449
 
450
### KDE default background
451
if [ ! $PSI ]; then
452
    if [ -e /usr/share/backgrounds/images/default.png ]; then
453
	cp -a customize/sl${OS_RELEASE}/default.png /usr/share/backgrounds/images/default.png
454
    fi
455
fi
456
 
457
### KDE startup/exit sound
458
if [ -e /usr/share/config/knotify.eventsrc ]; then
459
    cp -a customize/sl/knotify.eventsrc /usr/share/config/knotify.eventsrc
460
    cp -a customize/sl/kmixrc /usr/share/config/kmixrc
461
fi
462
 
463
### KDE session manager; start at login
464
#   kmix, krandrtray
74 beyerle@PS 465
# if [ -e /usr/share/config/ksmserverrc ]; then
466
#    cp -a customize/sl/ksmserverrc /usr/share/config/ksmserverrc
467
# fi    
468
#
469
##  now done in runlast by coping .desktop files to .kde/Autostart
470
# 
1 beyerle@PS 471
 
472
### Configure SELinux
473
if [ $SELINUX ]; then
474
    if [ -e /etc/selinux/config ]; then
475
	sed -i "s|^SELINUX=.*|SELINUX=$SELINUX|" /etc/selinux/config
476
    fi
477
fi
478
 
479
### Do not like jumping CD icon when starting autorun.desktop
480
if [ -e /etc/skel/.kde/Autostart/Autorun.desktop ]; then
481
    grep -q "StartupNotify=false" /etc/skel/.kde/Autostart/Autorun.desktop
482
    if [ "$?" != "0" ]; then
483
	echo "StartupNotify=false" >> /etc/skel/.kde/Autostart/Autorun.desktop
484
    fi
485
fi
486
 
487
echo "done."
488
echo "--------------------------------------------"
489
 
490
 
491
 
492
###############################################################
493
# Add-ons
494
###############################################################
495
 
496
echo "Add-ons ..."
497
 
498
### System icon on desktop
499
if [ -d /usr/share/apps/kdesktop/DesktopLinks ]; then
500
    cp -a customize/System.desktop /usr/share/apps/kdesktop/DesktopLinks/
501
fi
502
 
503
### files for PSI User, will be copied during bootup to /home/$LOCALUSER/
504
if [ $PSI ]; then
505
    rm -rf /usr/share/$LOCALUSER
506
    cp -a customize/$LOCALUSER /usr/share/
507
fi
508
 
509
### psi-menu, psi-scanvirus
510
if [ $PSI ]; then
511
    cp -a customize/psi/psi-menu /usr/bin/
512
    cp -a customize/psi/psi-scanvirus /usr/bin/
513
    [ -d /usr/local/uvscan ] && cp -a customize/psi/update-dat /usr/local/uvscan/
514
    [ -x /usr/bin/freshclam ] && cp -a customize/psi/psi-freshclam /usr/bin/
515
fi
516
 
23 beyerle@PS 517
### script to install LiveCD on local harddisk
31 beyerle@PS 518
cp -a customize/livecd-install  /usr/bin/
16 beyerle@PS 519
 
52 beyerle@PS 520
### GUI for livecd-install
55 beyerle@PS 521
cp -a customize/livecd-install-gui/livecd-install-gui /usr/sbin/
66 beyerle@PS 522
ln -fs consolehelper /usr/bin/livecd-install-gui
55 beyerle@PS 523
cp -a customize/livecd-install-gui/livecd-install-gui.desktop /usr/share/applications/
524
cp -a customize/livecd-install-gui/livecd-install-gui.console.apps /etc/security/console.apps/livecd-install-gui
525
cp -a customize/livecd-install-gui/livecd-install-gui.pam.d /etc/pam.d/livecd-install-gui
52 beyerle@PS 526
 
55 beyerle@PS 527
 
23 beyerle@PS 528
### livecd-mkinitrd (used by livecd-install)
20 beyerle@PS 529
if [ -e customize/sl${OS_RELEASE}/livecd-mkinitrd ]; then
530
    cp -a customize/sl${OS_RELEASE}/livecd-mkinitrd /usr/sbin/
531
else
532
    cp -a /sbin/mkinitrd /usr/sbin/livecd-mkinitrd
533
fi
534
 
535
 
1 beyerle@PS 536
echo "done."
537
echo "--------------------------------------------"
538
 
539
 
540
 
541
###############################################################
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
 
551
cp -a customize/kudzu-auto /etc/init.d/kudzu-auto
552
chmod +x /etc/rc.d/init.d/kudzu-auto
553
ln -sf /etc/rc.d/init.d/kudzu-auto /etc/rc.d/rc5.d/S04kudzu-auto
554
ln -sf /etc/rc.d/init.d/kudzu-auto /etc/rc.d/rc3.d/S04kudzu-auto
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
 
14 beyerle@PS 685
if [ $PSI ]; then
686
    cp -a customize/psi/cron_psi /etc/cron.d/psi
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
 
703
if [ $PSI ]; then
704
    chkconfig cfenvd off 2>/dev/null
705
    chkconfig cfexecd off 2>/dev/null
706
    chkconfig cfservd off 2>/dev/null
707
fi
708
if [ ! "$SERVICES_OFF" = "" ]; then
709
    for service in $SERVICES_OFF; do
710
	chkconfig $service off 2>/dev/null
711
    done
712
fi
713
# we do kudzu-auto
714
chkconfig kudzu off 
715
 
716
 
23 beyerle@PS 717
### services on
1 beyerle@PS 718
 
719
if [ $PSI ]; then
720
    chkconfig vpnclient_init on 2>/dev/null
721
fi
722
if [ ! "$SERVICES_ON" = "" ]; then
723
    for service in $SERVICES_ON; do
724
	chkconfig $service on 2>/dev/null
725
    done
726
fi
727
 
728
echo "done."
729
echo "--------------------------------------------"
730
 
731
 
732
###############################################################
733
# Empty files
734
###############################################################
735
 
736
echo "Empty files ..."
737
 
738
### /etc/security/users
739
if [ $PSI ]; then
740
    rm -f /etc/security/users
741
    touch /etc/security/users
742
fi
743
 
744
### Files to empty
745
FILES_TOUCH="/etc/sysconfig/hwconf \
746
             /etc/resolv.conf \
747
             /etc/adjtime \
748
             /etc/modprobe.conf \
749
             /etc/dhclient-eth0.conf"
750
 
751
for file in $FILES_TOUCH; do
752
    rm -rf $file
753
    touch $file
754
done
755
 
756
echo "done."
757
echo "--------------------------------------------"
758
 
759
 
760
###############################################################
761
# Update locate db, prelink, makewhatis
762
###############################################################
763
 
95 beyerle@PS 764
### run updatedb
1 beyerle@PS 765
if [ -x /usr/bin/updatedb ]; then
766
    echo "Run updatedb..."
767
    . /etc/updatedb.conf 2>/dev/null
768
    rpm -q mlocate >/dev/null
769
    if [ "$?" = "0" ]; then
41 beyerle@PS 770
	/usr/bin/updatedb -e "/media /sfs /tmp /boot /livecd /home /net /trunk"
1 beyerle@PS 771
    else
41 beyerle@PS 772
	/usr/bin/updatedb -e /media,/tmp,/boot,/livecd,/home,/net,/trunk
1 beyerle@PS 773
    fi
774
    echo "done."
775
fi
776
 
777
### run prelink
778
if [ -x /etc/cron.daily/prelink ]; then
779
    echo "Run prelink..."
780
    /etc/cron.daily/prelink
781
    echo "done."
782
fi
783
if [ -x /etc/cron_backup/prelink ]; then
784
    echo "Run prelink..."
785
    /etc/cron_backup/prelink
786
    echo "done."
787
fi
23 beyerle@PS 788
 
789
### clean prelink log
1 beyerle@PS 790
rm -f /var/log/prelink/prelink.log 2>/dev/null
791
rm -f /var/log/prelink.log 2>/dev/null
792
 
793
### run makewhatis
794
if [ -x /usr/bin/makewhatis ]; then
795
    echo "Run makewhatis..."
796
    makewhatis -u -w
797
fi
798
 
799
echo "done."
800
echo "--------------------------------------------"
801
 
802
###############################################################