Subversion Repositories livecd

Rev

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