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