Subversion Repositories livecd

Rev

Details | 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)
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
# umount PSI master
23 beyerle@PS 141
[ $PSI ] && umount /mnt/master 2>/dev/null
1 beyerle@PS 142
 
143
# copy back /etc/yum.repos.d
144
if [ ! $PSI ]; then
145
    if [ -d /etc/yum.repos.d.ori ]; then
146
	cp -a /etc/yum.repos.d.ori /etc/yum.repos.d
147
    fi
148
fi
149
 
150
# run cfagent
151
if [ $PSI ]; then
152
    # cfagent needs running afs
153
    /etc/init.d/afs start
154
    echo "Run cfagent ..."
155
    cfagent
156
fi
157
 
158
echo "done."
159
echo "--------------------------------------------"
160
 
161
 
162
 
163
###############################################################
164
# Clean up and delete files
165
###############################################################
166
 
167
echo "Cleaning up ..."
168
 
169
### set LANG
170
export LANG=C
171
 
172
### stop AFS
173
/etc/init.d/afs stop 2>/dev/null
174
 
175
### clean up yum
176
yum clean all >/dev/null
177
rm -rf /var/cache/yum/*
178
 
179
### remove cfengine log files
180
rm -f /var/cfengine/*log
181
 
182
### delete log files
183
find /var/log/ -type f -exec rm -f {} \;
184
 
185
### clean rpm database
186
rm -rf /var/lib/rpm/__db.*
187
 
188
### clean /var/spool/mail
189
rm -rf /var/spool/mail/*
190
touch /var/spool/mail/root
191
chmod 600 /var/spool/mail/root
192
 
193
### delete .cfsaved Files
194
if [ $PSI ]; then
195
    echo -n "Delete .cfsaved Files, please wait: "
196
    find / -xdev -name "*\.cfsaved" -exec rm -f {} \;
197
    echo "ok."
198
fi
199
 
200
### delete .rpmori .rpm Files in /etc
201
find /etc -name "*\.rpmorig" -exec rm -f {} \;
202
find /etc -name "*\.rpmnew"  -exec rm -f {} \;
29 beyerle@PS 203
find /etc -name "*\.rpmsave" -exec rm -f {} \;
1 beyerle@PS 204
 
205
### delete *~ files in /etc
206
find /etc | grep "~$" | while read f; do rm -f "$f"; done
207
 
208
### clean up /root
56 beyerle@PS 209
rm -f  /root/.bash_history
210
rm -f  /root/.ssh/known_hosts
211
rm -rf /root/.subversion
1 beyerle@PS 212
 
213
### clean AFS cache
214
if [ -d /usr/vice/cache ]; then
215
    rm -rf /usr/vice/cache
216
    mkdir /usr/vice/cache
217
fi
218
if [ -d /var/cache/openafs ]; then
219
    rm -rf /var/cache/openafs
220
    mkdir /var/cache/openafs
221
fi
222
 
223
### clean up /var/tmp
224
rm -rf /var/tmp/*
225
 
226
### remove root passwd
227
sed -i "s|^root:.*|root:\*:12943:0:99999:7:::|" /etc/shadow
228
sed -i "s|^root:.*:0:0|root:x:0:0|" /etc/passwd
229
 
230
### remove /.autofsck
23 beyerle@PS 231
rm -f /.autofsck
1 beyerle@PS 232
 
233
### disable cfagent
234
rm -f /etc/cron.d/cfengine
235
 
236
### disable check_update in rc.local.psi
23 beyerle@PS 237
[ $PSI ] && sed -i "s|/etc/init.d/check_update|# /etc/init.d/check_update|" /etc/rc.d/rc.local.psi
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
 
243
### Files to remove
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
255
mv /etc/cron.d/sysstat /etc/cron_backup/ 2>/dev/null
256
mv /etc/cron.daily/00-makewhatis.cron /etc/cron_backup/ 2>/dev/null
257
mv /etc/cron.weekly/00-makewhatis.cron /etc/cron_backup/00-makewhatis.cron.weekly 2>/dev/null
258
mv /etc/cron.daily/rpm /etc/cron_backup/ 2>/dev/null
259
mv /etc/cron.daily/slocate.cron /etc/cron_backup/ 2>/dev/null
260
mv /etc/cron.daily/tetex.cron /etc/cron_backup/ 2>/dev/null
261
mv /etc/cron.daily/yum.cron /etc/cron_backup/ 2>/dev/null
262
mv /etc/cron.daily/prelink /etc/cron_backup/ 2>/dev/null
263
mv /etc/cron.daily/00-logwatch /etc/cron_backup/ 2>/dev/null
264
 
265
### remove desktop entry from crossover
23 beyerle@PS 266
[ $PSI ] && rm -f "/usr/share/apps/kdesktop/DesktopLinks/Internet Explorer.desktop"
1 beyerle@PS 267
 
268
### remove backup of /etc/X11/xorg.conf
269
rm -f /etc/X11/xorg.conf.ori 2>/dev/null
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
284
 
285
### move some unneeded files to /mini (not for LiveDVD and miniCD)
286
if [ ! $DVD ] && [ ! $MINI ]; then
287
    # to save disk space
288
 
289
    mkdir -p /mini
290
 
291
    # move some dirs in /usr/share/doc to /mini
292
    mkdir -p /mini/usr/share/doc
293
    mv /usr/share/doc/openafs-* /mini/usr/share/doc 2>/dev/null
294
    mv /usr/share/doc/gcc-*     /mini/usr/share/doc 2>/dev/null
295
    mv /usr/share/doc/pine-*     /mini/usr/share/doc 2>/dev/null
296
    mv /usr/share/doc/ntp-*     /mini/usr/share/doc 2>/dev/null
297
 
298
    # move zipped java source to /mini, if j2sdk is installed
299
    java_src=$( rpm -ql j2sdk 2>/dev/null | grep src.zip )
300
    [ -e "$java_src" ] && mv "$java_src" /mini/
301
fi
302
 
33 beyerle@PS 303
### remove /etc/rc.d/init.d/login (should only be on Mini LiveCD)
304
##  this will be obsolete soon.
305
rm -f /etc/rc.d/init.d/login
306
 
307
 
1 beyerle@PS 308
echo "done."
309
echo "--------------------------------------------"
310
 
311
 
312
 
313
###############################################################
314
# Modify files
315
###############################################################
316
 
317
echo "Modify files ..."
318
 
319
### remove AFS startup warning about cache
23 beyerle@PS 320
[ $PSI ] && sed  -i "/\!\!\!/d" /etc/init.d/afs
1 beyerle@PS 321
 
322
### disable umount of loop device during shutdown
323
#   this is done really dirty at the moment:
324
#    -> just replace "loop" with non existing device "lo_fake"
325
 
326
[ -e /etc/init.d/netfs ]     && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/netfs
327
[ -e /etc/init.d/autofs ]    && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/autofs
328
[ -e /etc/init.d/halt ]      && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/halt
329
[ -e /etc/init.d/functions ] && sed -i "s|/loop/|/lo_fake/|g" /etc/init.d/functions
330
 
331
# do not shuttdown loopback interface
332
sed -i "s|[^#]action \$\"Shutting down loopback interface:|\t#action \$\"Shutting down loopback interface:|" /etc/init.d/network
333
 
334
### copy new /etc/init.d/halt 
335
cp -a customize/sl${OS_RELEASE}/halt /etc/init.d/halt
336
 
337
### in /etc/rc.d/rc.sysinit
338
#   comment out 'initlog -c "fsck -T -a $rootdev $fsckoptions"' 
339
#   to disable fsck of root filesystem
340
sed -i "s|\tfsck -T -a \$rootdev|\tsleep 0; #fsck -T -a \$rootdev|" /etc/rc.d/rc.sysinit
341
sed -i "s|\tinitlog -c \"fsck -T -a \$rootdev|\tsleep 0; #initlog -c \"fsck -T -a \$rootdev|" /etc/rc.d/rc.sysinit
342
#   disable "Remounting root filesystem in read-write mode"
343
sed -i "s| action \$\"Remounting root filesystem|#action \$\"Remounting root filesystem|" /etc/rc.d/rc.sysinit
344
 
345
### start afs with option -memcache !
346
if [ -e /etc/sysconfig/afs ]; then
347
    if [ $PSI ]; then
348
	sed -i "s|^EXTRA_OPTIONS=.*|EXTRA_OPTIONS='-fakestat -memcache'|" /etc/sysconfig/afs
349
    else
350
	grep -q "\-fakestat \-memcache" /etc/sysconfig/afs
351
	if [ "$?" != "0" ]; then
352
	    sed -i "s|-fakestat|-fakestat -memcache|" /etc/sysconfig/afs
353
	fi
354
    fi
355
fi
356
 
357
### source /etc/sysconfig/cfengine
358
[ $PSI ] && . /etc/sysconfig/cfengine
359
 
360
### Set /etc/motd
23 beyerle@PS 361
LiveCD="LiveCD"
362
[ "$ARCH" = "x86_64" ] && LiveCD="LiveCD 64bit"
363
echo "Welcome to $LIVECD_OS ${LiveCD}" > /etc/motd
364
[ $PSI ] && echo "Welcome to PSI ${LiveCD} (${CLASS} ${SUBCLASS} SL${RELEASE})" > /etc/motd
68 beyerle@PS 365
[ $DVD ]  && sed -i "s|CD|DVD|"    /etc/motd
366
[ $MINI ] && sed -i "s|CD|MiniCD|" /etc/motd
1 beyerle@PS 367
 
368
### Set hostname to psi or slinux (not really necessary)
369
if [ $PSI ]; then
370
    HOSTNAME="psi"
371
    sed -i "s/hostname=.*/hostname=${HOSTNAME}.psi.ch/" /etc/ssmtp/ssmtp.conf
372
    sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/cfengine
373
else
23 beyerle@PS 374
    HOSTNAME="$DEFAULT_HOSTNAME"
375
fi
1 beyerle@PS 376
 
377
# change hostname
378
sed -i "s/HOSTNAME=.*/HOSTNAME=${HOSTNAME}/" /etc/sysconfig/network
379
sed -i "s/DHCP_HOSTNAME=.*/DHCP_HOSTNAME==${HOSTNAME}/" /etc/sysconfig/networking/devices/ifcfg-eth0 2>/dev/null
380
 
381
### Modify /etc/redhat-release
67 beyerle@PS 382
ADD=" - Live"
1 beyerle@PS 383
grep -q "$ADD" /etc/redhat-release
384
if [ "$?" != "0" ]; then
67 beyerle@PS 385
    echo "$( cat /etc/redhat-release )${ADD}CD" > /etc/redhat-release
1 beyerle@PS 386
fi
67 beyerle@PS 387
[ $DVD ]  && sed -i "s|CD|DVD|"    /etc/redhat-release
388
[ $MINI ] && sed -i "s|CD|MiniCD|" /etc/redhat-release
1 beyerle@PS 389
 
390
### Make scratch
391
if [ $PSI ]; then
392
    rm -rf /home/scratch
393
    mkdir -p /home/scratch
394
    chmod 1777 /home/scratch
395
    rm -rf /scratch
396
    ln -s /home/scratch /scratch
397
else
398
    rm -rf /home/scratch
399
    rm -rf /scratch
400
    mkdir -p /scratch
401
    chmod 1777 /scratch
402
fi
403
 
404
### set default runlevel to $RUNLEVEL
405
if [ $RUNLEVEL ]; then
406
    sed -i "s/id:.:initdefault:/id:$RUNLEVEL:initdefault:/" /etc/inittab
407
fi
408
 
409
### edit /etc/sysconfig/desktop
410
if [ $DESKTOP ]; then
411
    sed -i "/^DESKTOP=.*/d" /etc/sysconfig/desktop 2&>/dev/null
412
    echo "DESKTOP=$DESKTOP" >> /etc/sysconfig/desktop
413
fi
414
if [ $DISPLAYMANAGER ]; then
415
    sed -i "/^DISPLAYMANAGER=.*/d" /etc/sysconfig/desktop 2&>/dev/null
416
    echo "DISPLAYMANAGER=$DISPLAYMANAGER" >> /etc/sysconfig/desktop
417
fi
418
 
419
### GDM login background
420
if [ -e /usr/share/gdm/themes/SL/background.png ]; then
421
    cp -a customize/sl${OS_RELEASE}/background.png /usr/share/gdm/themes/SL/background.png
422
fi
423
 
424
### KDE default background
425
if [ ! $PSI ]; then
426
    if [ -e /usr/share/backgrounds/images/default.png ]; then
427
	cp -a customize/sl${OS_RELEASE}/default.png /usr/share/backgrounds/images/default.png
428
    fi
429
fi
430
 
431
### KDE startup/exit sound
432
if [ -e /usr/share/config/knotify.eventsrc ]; then
433
    cp -a customize/sl/knotify.eventsrc /usr/share/config/knotify.eventsrc
434
    cp -a customize/sl/kmixrc /usr/share/config/kmixrc
435
fi
436
 
437
### KDE session manager; start at login
438
#   kmix, krandrtray
439
if [ -e /usr/share/config/ksmserverrc ]; then
440
    cp -a customize/sl/ksmserverrc /usr/share/config/ksmserverrc
441
fi    
442
 
443
### Configure SELinux
444
if [ $SELINUX ]; then
445
    if [ -e /etc/selinux/config ]; then
446
	sed -i "s|^SELINUX=.*|SELINUX=$SELINUX|" /etc/selinux/config
447
    fi
448
fi
449
 
450
### Do not like jumping CD icon when starting autorun.desktop
451
if [ -e /etc/skel/.kde/Autostart/Autorun.desktop ]; then
452
    grep -q "StartupNotify=false" /etc/skel/.kde/Autostart/Autorun.desktop
453
    if [ "$?" != "0" ]; then
454
	echo "StartupNotify=false" >> /etc/skel/.kde/Autostart/Autorun.desktop
455
    fi
456
fi
457
 
458
echo "done."
459
echo "--------------------------------------------"
460
 
461
 
462
 
463
###############################################################
464
# Add-ons
465
###############################################################
466
 
467
echo "Add-ons ..."
468
 
469
### System icon on desktop
470
if [ -d /usr/share/apps/kdesktop/DesktopLinks ]; then
471
    cp -a customize/System.desktop /usr/share/apps/kdesktop/DesktopLinks/
472
fi
473
 
474
### files for PSI User, will be copied during bootup to /home/$LOCALUSER/
475
if [ $PSI ]; then
476
    rm -rf /usr/share/$LOCALUSER
477
    cp -a customize/$LOCALUSER /usr/share/
478
fi
479
 
480
### psi-menu, psi-scanvirus
481
if [ $PSI ]; then
482
    cp -a customize/psi/psi-menu /usr/bin/
483
    cp -a customize/psi/psi-scanvirus /usr/bin/
484
    [ -d /usr/local/uvscan ] && cp -a customize/psi/update-dat /usr/local/uvscan/
485
    [ -x /usr/bin/freshclam ] && cp -a customize/psi/psi-freshclam /usr/bin/
486
fi
487
 
23 beyerle@PS 488
### script to install LiveCD on local harddisk
31 beyerle@PS 489
cp -a customize/livecd-install  /usr/bin/
16 beyerle@PS 490
 
52 beyerle@PS 491
### GUI for livecd-install
55 beyerle@PS 492
cp -a customize/livecd-install-gui/livecd-install-gui /usr/sbin/
66 beyerle@PS 493
ln -fs consolehelper /usr/bin/livecd-install-gui
55 beyerle@PS 494
cp -a customize/livecd-install-gui/livecd-install-gui.desktop /usr/share/applications/
495
cp -a customize/livecd-install-gui/livecd-install-gui.console.apps /etc/security/console.apps/livecd-install-gui
496
cp -a customize/livecd-install-gui/livecd-install-gui.pam.d /etc/pam.d/livecd-install-gui
52 beyerle@PS 497
 
55 beyerle@PS 498
 
23 beyerle@PS 499
### livecd-mkinitrd (used by livecd-install)
20 beyerle@PS 500
if [ -e customize/sl${OS_RELEASE}/livecd-mkinitrd ]; then
501
    cp -a customize/sl${OS_RELEASE}/livecd-mkinitrd /usr/sbin/
502
else
503
    cp -a /sbin/mkinitrd /usr/sbin/livecd-mkinitrd
504
fi
505
 
506
 
1 beyerle@PS 507
echo "done."
508
echo "--------------------------------------------"
509
 
510
 
511
 
512
###############################################################
513
# Create special files
514
###############################################################
515
 
516
echo "Create special files ..."
517
 
518
###############################################################
519
# /etc/rc.d/init.d/kudzu-auto
520
### Noninteractive HW detection and configuration
521
 
522
cp -a customize/kudzu-auto /etc/init.d/kudzu-auto
523
chmod +x /etc/rc.d/init.d/kudzu-auto
524
ln -sf /etc/rc.d/init.d/kudzu-auto /etc/rc.d/rc5.d/S04kudzu-auto
525
ln -sf /etc/rc.d/init.d/kudzu-auto /etc/rc.d/rc3.d/S04kudzu-auto
526
 
527
 
528
###############################################################
529
# /etc/rc.d/init.d/runveryfirst
530
### Fix some things during bootup - run VERY first
531
# runveryfirst will run at the begining of /etc/rc.d/rc.sysinit
532
 
533
cp -a customize/runveryfirst /etc/init.d/runveryfirst
534
chmod +x /etc/rc.d/init.d/runveryfirst
535
 
536
# execute runveryfirst just before "Initialize hardware"
537
grep -q runveryfirst /etc/rc.d/rc.sysinit
538
if [ "$?" != "0" ]; then
539
    sed -i -e "/^# Initialize hardware/a\/etc\/init.d\/runveryfirst" /etc/rc.d/rc.sysinit
540
fi
541
 
542
 
543
###############################################################
544
# /etc/rc.d/init.d/runfirst
545
### Fix some things during bootup - run first
546
# runfirst will run at the end of /etc/rc.d/rc.sysinit
547
 
548
cp -a customize/runfirst /etc/init.d/runfirst
549
chmod +x /etc/rc.d/init.d/runfirst
550
 
551
sysinit_line="/etc/rc.d/init.d/runfirst"
552
grep -q "$sysinit_line" /etc/rc.d/rc.sysinit
553
if [ "$?" != "0" ]; then
554
    echo "$sysinit_line" >> /etc/rc.d/rc.sysinit
555
    echo >> /etc/rc.d/rc.sysinit
556
fi
557
 
14 beyerle@PS 558
 
1 beyerle@PS 559
###############################################################
560
# /etc/rc.d/init.d/runlast
561
### Fix some things during bootup - run last
562
 
563
cp -a customize/runlast /etc/init.d/runlast
564
chmod +x /etc/rc.d/init.d/runlast
565
 
566
### Add /etc/rc.d/init.d/runlast to rc.local
567
LINE=/etc/rc.d/init.d/runlast
568
grep -q $LINE /etc/rc.d/rc.local
569
if [ "$?" != "0" ]; then
570
    # add line
571
    echo "" >> /etc/rc.d/rc.local
572
    echo $LINE >> /etc/rc.d/rc.local
573
    echo "" >> /etc/rc.d/rc.local    
574
fi
575
 
14 beyerle@PS 576
 
1 beyerle@PS 577
###############################################################
578
# /usr/bin/save-localdata
579
### stores data on a usbstick
580
cp -a customize/save-localdata /usr/bin/save-localdata
581
chmod +x /usr/bin/save-localdata
582
 
583
# add /usr/bin/save-localdata to /etc/sudoers
584
grep -q "save-localdata" /etc/sudoers 2>/dev/null
585
if [ "$?" != "0" ]; then
586
    echo "$LOCALUSER ALL = NOPASSWD: /usr/bin/save-localdata" >> /etc/sudoers
587
fi
588
 
589
# create menu entry
590
cp -a customize/save-localdata.desktop /usr/share/applications/
591
 
14 beyerle@PS 592
 
1 beyerle@PS 593
###############################################################
594
# /usr/bin/set-volume
595
### unmute all mixers and set volumes
596
cp -a customize/set-volume /usr/bin/set-volume
597
chmod +x /usr/bin/set-volume
598
 
14 beyerle@PS 599
 
1 beyerle@PS 600
###############################################################
601
# /etc/sysconfig/networking/devices/ifcfg-eth0
602
# /etc/sysconfig/networking/devices/ifcfg-eth1
603
 
604
for iface in eth0 eth1; do 
605
 
606
    # remove it first
607
    rm -f /etc/sysconfig/networking/devices/ifcfg-${iface} 2>/dev/null
608
    rm -f /etc/sysconfig/networking/profiles/default/ifcfg-${iface} 2>/dev/null
609
    rm -f /etc/sysconfig/network-scripts/ifcfg-${iface} 2>/dev/null
610
 
611
    # create it, if we have a sample
612
    if [ -e customize/sl${OS_RELEASE}/ifcfg-${iface} ]; then
613
	cp -a customize/sl${OS_RELEASE}/ifcfg-${iface} /etc/sysconfig/networking/devices/ifcfg-${iface}
614
        # make hard links
615
	cp -lf /etc/sysconfig/networking/devices/ifcfg-${iface} /etc/sysconfig/networking/profiles/default/
616
	cp -lf /etc/sysconfig/networking/devices/ifcfg-${iface} /etc/sysconfig/network-scripts/
617
    fi
618
done
619
 
620
 
621
###############################################################
622
# /etc/profile.d/setsysfont.sh
623
### setsysfont 
624
cat > /etc/profile.d/setsysfont.sh <<EOF
625
# setsysfont once
626
if [ ! -e /tmp/.sysfont_has_been_set ]; then
627
    touch /tmp/.sysfont_has_been_set
628
    /bin/setfont 2>/dev/null
629
    /sbin/setsysfont 2>/dev/null
630
fi
631
EOF
632
chmod 755 /etc/profile.d/setsysfont.sh
633
 
14 beyerle@PS 634
 
1 beyerle@PS 635
###############################################################
636
# /etc/profile.d/setsysfont.csh
637
### setsysfont 
638
cat > /etc/profile.d/setsysfont.csh <<EOF
639
# setsysfont once
640
if ( ! -e /tmp/.sysfont_has_been_set ) then
641
    touch /tmp/.sysfont_has_been_set
642
    /bin/setfont 2>/dev/null
643
    /sbin/setsysfont 2>/dev/null
644
endif
645
EOF
646
chmod 755 /etc/profile.d/setsysfont.csh
647
 
14 beyerle@PS 648
 
1 beyerle@PS 649
###############################################################
650
# /etc/cron.d/psi
651
### PSI specific cronjobs
652
 
14 beyerle@PS 653
if [ $PSI ]; then
654
    cp -a customize/psi/cron_psi /etc/cron.d/psi
655
    chmod +x /etc/cron.d/psi
1 beyerle@PS 656
fi
657
 
658
echo "done."
659
echo "--------------------------------------------"
660
 
661
 
662
 
663
###############################################################
664
# Configure services
665
###############################################################
666
 
667
echo "Configure services ..."
668
 
23 beyerle@PS 669
### services off
1 beyerle@PS 670
 
671
if [ $PSI ]; then
672
    chkconfig cfenvd off 2>/dev/null
673
    chkconfig cfexecd off 2>/dev/null
674
    chkconfig cfservd off 2>/dev/null
675
fi
676
if [ ! "$SERVICES_OFF" = "" ]; then
677
    for service in $SERVICES_OFF; do
678
	chkconfig $service off 2>/dev/null
679
    done
680
fi
681
# we do kudzu-auto
682
chkconfig kudzu off 
683
 
684
 
23 beyerle@PS 685
### services on
1 beyerle@PS 686
 
687
if [ $PSI ]; then
688
    chkconfig vpnclient_init on 2>/dev/null
689
fi
690
if [ ! "$SERVICES_ON" = "" ]; then
691
    for service in $SERVICES_ON; do
692
	chkconfig $service on 2>/dev/null
693
    done
694
fi
695
 
696
echo "done."
697
echo "--------------------------------------------"
698
 
699
 
700
###############################################################
701
# Empty files
702
###############################################################
703
 
704
echo "Empty files ..."
705
 
706
### /etc/security/users
707
if [ $PSI ]; then
708
    rm -f /etc/security/users
709
    touch /etc/security/users
710
fi
711
 
712
### Files to empty
713
FILES_TOUCH="/etc/sysconfig/hwconf \
714
             /etc/resolv.conf \
715
             /etc/adjtime \
716
             /etc/modprobe.conf \
717
             /etc/dhclient-eth0.conf"
718
 
719
for file in $FILES_TOUCH; do
720
    rm -rf $file
721
    touch $file
722
done
723
 
724
echo "done."
725
echo "--------------------------------------------"
726
 
727
 
728
###############################################################
729
# Update locate db, prelink, makewhatis
730
###############################################################
731
 
732
### run slocate
733
if [ -x /usr/bin/updatedb ]; then
734
    echo "Run updatedb..."
735
    . /etc/updatedb.conf 2>/dev/null
736
    rpm -q mlocate >/dev/null
737
    if [ "$?" = "0" ]; then
41 beyerle@PS 738
	/usr/bin/updatedb -e "/media /sfs /tmp /boot /livecd /home /net /trunk"
1 beyerle@PS 739
    else
41 beyerle@PS 740
	/usr/bin/updatedb -e /media,/tmp,/boot,/livecd,/home,/net,/trunk
1 beyerle@PS 741
    fi
742
    echo "done."
743
fi
744
 
745
### run prelink
746
if [ -x /etc/cron.daily/prelink ]; then
747
    echo "Run prelink..."
748
    /etc/cron.daily/prelink
749
    echo "done."
750
fi
751
if [ -x /etc/cron_backup/prelink ]; then
752
    echo "Run prelink..."
753
    /etc/cron_backup/prelink
754
    echo "done."
755
fi
23 beyerle@PS 756
 
757
### clean prelink log
1 beyerle@PS 758
rm -f /var/log/prelink/prelink.log 2>/dev/null
759
rm -f /var/log/prelink.log 2>/dev/null
760
 
761
### run makewhatis
762
if [ -x /usr/bin/makewhatis ]; then
763
    echo "Run makewhatis..."
764
    makewhatis -u -w
765
fi
766
 
767
echo "done."
768
echo "--------------------------------------------"
769
 
770
###############################################################