Subversion Repositories livecd

Rev

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