Subversion Repositories livecd

Rev

Rev 26 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
15 beyerle@PS 1
#!/bin/bash
2
#
3
###############################################################
4
#
5
# Installes the LiveCD on local harddisk
6
# 
7
# Boot LiveCD and run this script as root
8
#
9
# Urs Beyerle, PSI
10
#
11
###############################################################
12
 
13
 
14
###############################################################
15
# Definitions
16
###############################################################
17
 
18
# files which should be restored from .ori files
19
FILES_RESTORE="/etc/init.d/netfs \
20
           /etc/init.d/autofs \
21
           /etc/init.d/halt \
22
           /etc/init.d/network
23
           /etc/init.d/functions \
24
           /etc/rc.d/rc.sysinit \
25
           /etc/sysconfig/afs \
26
           /etc/motd \
27
           /etc/redhat-release \
16 beyerle@PS 28
	   /etc/rc.d/rc.local \
15 beyerle@PS 29
           /etc/rc.d/rc.sysinit"
30
 
16 beyerle@PS 31
LIVECD_INIT_SCRIPTS="runfirst \
32
                    runveryfirst \
33
                    runlast \
34
                    kudzu-auto"
15 beyerle@PS 35
 
36
# Main directories which should be not be copied
16 beyerle@PS 37
DIR_NOT_COPY="/proc \
38
              /dev \
39
              /livecd \
40
              /boot \
41
              /afs \
42
              /sys \
43
              /mnt \
44
              /media"
15 beyerle@PS 45
 
46
# Mount point of the new SL system
47
NEW=/mnt/harddisk
48
 
21 beyerle@PS 49
# Name of the script
15 beyerle@PS 50
SCRIPTNAME=$( basename $0 )
51
 
16 beyerle@PS 52
 
53
 
21 beyerle@PS 54
 
15 beyerle@PS 55
###############################################################
56
# Functions
57
###############################################################
58
 
59
function usage() {
60
 
61
   ## Usage
62
   # ----------------------------------------------------------
63
 
64
   cat <<EOF
21 beyerle@PS 65
 
22 beyerle@PS 66
  $SCRIPTNAME [OPTIONS] -mbr=[DEVICE] [PARTITION]
15 beyerle@PS 67
 
26 beyerle@PS 68
    Installes LiveCD on PARTITION and the bootloader grub into 
69
    the Master Boot Record (MBR) of DEVICE. The MBR will be 
70
    backed up to PARTITION.
15 beyerle@PS 71
 
21 beyerle@PS 72
  OPTIONS:
15 beyerle@PS 73
 
26 beyerle@PS 74
    -h   --help         Print this screen
75
    -swap=[partition]   Use [partition] as swap
76
    -win=[partition]    Your active Windows partition. If not given, 
22 beyerle@PS 77
                        $SCRIPTNAME tries to find it
26 beyerle@PS 78
    -nogrub             Do not install grub. You have to install 
79
                        manually a bootloader (not recommended)
80
    -floppy             Needed, if grub should be installed on floppy
81
    -y                  Answer all questions with yes
15 beyerle@PS 82
 
21 beyerle@PS 83
  Example:
84
 
22 beyerle@PS 85
  $SCRIPTNAME -swap=/dev/sda3 -mbr=/dev/sda /dev/sda2
21 beyerle@PS 86
 
87
    Will install LiveCD on /dev/sda2 (= second partition on 
88
    first SATA disk). All data on /dev/sda2 will be deleted.
89
    /dev/sda3 has to be a Linux Swap partion. GRUB will be 
90
    installed in the MBR of /dev/sda (= first SATA disk).
91
 
15 beyerle@PS 92
EOF
93
}
94
 
95
 
21 beyerle@PS 96
function exit_now() {
97
 
98
    local exitcode=$1
99
    umount $INSTALL_PART 2>/dev/null
100
    exit $exitcode
101
}
102
 
103
 
104
 
15 beyerle@PS 105
###############################################################
106
# Main
107
###############################################################
108
 
16 beyerle@PS 109
### are we root?
110
### -----------------------------------------------------------
15 beyerle@PS 111
if [ "$( whoami )" != "root" ]; then
22 beyerle@PS 112
    echo "Please run this script as roo/home/l_beyerle/svn-livecd/livecd/trunkt."
21 beyerle@PS 113
    exit_now 1
15 beyerle@PS 114
fi
115
 
16 beyerle@PS 116
 
15 beyerle@PS 117
### read options from command-line
16 beyerle@PS 118
### -----------------------------------------------------------
15 beyerle@PS 119
while [ $# -gt 0 ]; do
120
 
121
    case "$1" in
122
       -h)
21 beyerle@PS 123
            usage; exit_now;;
22 beyerle@PS 124
 
21 beyerle@PS 125
       --help)
126
            usage; exit_now;;
22 beyerle@PS 127
 
24 beyerle@PS 128
       -swap*)
22 beyerle@PS 129
           if echo $1 | grep -q '=' ; then
130
	       SWAP_PART=$( echo $1 | sed 's/^-swap=//' )
131
	   else
132
	       shift
24 beyerle@PS 133
               SWAP_PART=$1
22 beyerle@PS 134
	   fi
135
	   shift; continue;;
136
 
24 beyerle@PS 137
       -mbr*)
22 beyerle@PS 138
           if echo $1 | grep -q '=' ; then
139
	       MBR_DEV=$( echo $1 | sed 's/^-mbr=//' )
140
	   else
141
	       shift
24 beyerle@PS 142
               MBR_DEV=$1
22 beyerle@PS 143
	   fi
144
	   shift; continue;;
145
 
24 beyerle@PS 146
       -win*)
22 beyerle@PS 147
           if echo $1 | grep -q '=' ; then
148
	       WIN_PART=$( echo $1 | sed 's/^-win=//' )
149
	   else
150
	       shift
24 beyerle@PS 151
               WIN_PART=$1
22 beyerle@PS 152
	   fi
153
	   shift; continue;;
154
 
16 beyerle@PS 155
       -nogrub)
156
            NOGRUB=$1; shift; continue;;
22 beyerle@PS 157
 
18 beyerle@PS 158
       -floppy)
159
            FLOPPY=$1; shift; continue;;
22 beyerle@PS 160
 
15 beyerle@PS 161
       -y)
162
            YES=$1; shift; continue;;
163
 
164
       *)
165
            INSTALL_PART=$1; break;;
166
    esac
167
 
168
done
169
echo
170
 
16 beyerle@PS 171
 
22 beyerle@PS 172
### test if $INSTALL_PART is defined and exists
173
### -----------------------------------------------------------
174
if [ ! $INSTALL_PART ]; then
175
    echo "No partition defined for installation"
176
    echo "Please see '$SCRIPTNAME -h'."; echo
177
    exit_now 1
178
fi
179
 
180
 
15 beyerle@PS 181
### test if MBR_DEV is given
16 beyerle@PS 182
### -----------------------------------------------------------
183
if [ ! $NOGRUB ]; then
184
    if [ ! $MBR_DEV ]; then
18 beyerle@PS 185
	echo "No MBR device defined."
16 beyerle@PS 186
	echo "Please see '$SCRIPTNAME -h'."; echo
21 beyerle@PS 187
	exit_now 1
16 beyerle@PS 188
    fi
15 beyerle@PS 189
fi
190
 
16 beyerle@PS 191
 
15 beyerle@PS 192
### test if $INSTALL_PART exists
16 beyerle@PS 193
### -----------------------------------------------------------
15 beyerle@PS 194
fdisk -l | cut -d" " -f1 | grep -q "^${INSTALL_PART}$"
195
if [ "$?" != "0" ]; then
196
    echo "Partition $INSTALL_PART not found! (see 'disk -l')"; echo
21 beyerle@PS 197
    exit_now 1
15 beyerle@PS 198
fi
199
 
16 beyerle@PS 200
 
15 beyerle@PS 201
### set $INSTALL_DEV (eg. /dev/sda)
16 beyerle@PS 202
### -----------------------------------------------------------
15 beyerle@PS 203
INSTALL_DEV=$( echo "$INSTALL_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
204
INSTALL_PART_NR=$( echo "$INSTALL_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
205
 
206
 
207
### test if $SWAP_PART exists
16 beyerle@PS 208
### -----------------------------------------------------------
15 beyerle@PS 209
if [ $SWAP_PART ]; then
210
    fdisk -l | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
211
    if [ "$?" != "0" ]; then
212
	echo "Swap partition $SWAP_PART not found! (see 'disk -l')"; echo
21 beyerle@PS 213
	exit_now 1
15 beyerle@PS 214
    fi
215
    fdisk -l | grep "Linux swap" | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
216
    if [ "$?" != "0" ]; then
26 beyerle@PS 217
	echo "Partition $SWAP_PART is not a Linux swap partition! (see 'disk -l')"
218
	echo "Use fdisk to create a Linux swap partition!"; echo
21 beyerle@PS 219
	exit_now 1
15 beyerle@PS 220
    fi
221
fi
222
 
223
 
224
### print warning
16 beyerle@PS 225
### -----------------------------------------------------------
26 beyerle@PS 226
echo                     "------------------------------------------------------------"
227
echo                     "   LiveCD will be installed on partition $INSTALL_PART"
15 beyerle@PS 228
[ "$SWAP_PART" ] && echo " Partition $SWAP_PART will be used as swap partition."
26 beyerle@PS 229
[ ! $NOGRUB ]    && echo " GRUB will be installed in Master Boot Record of $MBR_DEV"
230
echo                     "       !! All data on $INSTALL_PART will be lost !!"
231
echo                     "------------------------------------------------------------"
15 beyerle@PS 232
echo
16 beyerle@PS 233
 
15 beyerle@PS 234
 
26 beyerle@PS 235
### continue?
16 beyerle@PS 236
### -----------------------------------------------------------
15 beyerle@PS 237
if [ ! $YES ]; then
238
    echo -n "Continue (y/N)? "
18 beyerle@PS 239
    read key
15 beyerle@PS 240
    echo
21 beyerle@PS 241
    [ "$key" != "y" ] && exit_now 0
15 beyerle@PS 242
fi
243
 
244
 
26 beyerle@PS 245
### format $SWAP_PART
21 beyerle@PS 246
### -----------------------------------------------------------
26 beyerle@PS 247
if [ $SWAP_PART ]; then
248
    echo "Make swap on $SWAP_PART ..."
249
    mkswap $SWAP_PART
24 beyerle@PS 250
    echo
251
fi
21 beyerle@PS 252
 
253
 
15 beyerle@PS 254
### format $INSTALL_PART
16 beyerle@PS 255
### -----------------------------------------------------------
15 beyerle@PS 256
echo -n "Format $INSTALL_PART, please wait ... " 
21 beyerle@PS 257
mkfs.ext3 -q $INSTALL_PART || exit_now 1
15 beyerle@PS 258
echo "done."; echo
259
 
260
 
261
### mount $INSTALL_PART
16 beyerle@PS 262
### -----------------------------------------------------------
15 beyerle@PS 263
echo -n "Try to mount $INSTALL_PART to $NEW ... "
264
mkdir -p $NEW
21 beyerle@PS 265
mount $INSTALL_PART $NEW || exit_now 1
15 beyerle@PS 266
echo "done."; echo
267
 
268
 
269
### copy root dirs
16 beyerle@PS 270
### -----------------------------------------------------------
26 beyerle@PS 271
echo "Copy Live System to $INSTALL_PART ..."
15 beyerle@PS 272
root_dirs=$( ls / )
273
for dir in $root_dirs; do
274
    # check if dir is not in $DIR_NOT_COPY
275
    do_not_copy=""
276
    for not_dir in $DIR_NOT_COPY; do
277
	if [ "$not_dir" = "/$dir" ]; then 
278
	    do_not_copy="yes"
279
	    break
280
	fi
281
    done
282
    # do not copy links
283
    [ -L /$dir ] && do_not_copy="yes"
284
 
21 beyerle@PS 285
    fail=""
15 beyerle@PS 286
    if [ ! $do_not_copy ]; then
287
	echo -n "  * Copy  /$dir ... "
21 beyerle@PS 288
	cp -a /$dir $NEW || fail=true
15 beyerle@PS 289
	echo "done."
290
    fi
291
done
292
echo
21 beyerle@PS 293
if [ $fail ]; then
294
    echo "ERROR: Not everything was copied to $INSTALL_PART"
295
    exit_now 1
296
fi
15 beyerle@PS 297
 
298
 
16 beyerle@PS 299
### move /usr/opt back to /opt
300
### -----------------------------------------------------------
15 beyerle@PS 301
if [ -d $NEW/usr/opt ]; then
302
    echo -n "Move /opt back ... "
303
    mv $NEW/usr/opt $NEW/
304
    echo "done."; echo
305
fi
306
 
307
 
308
### create dirs which were not copied
16 beyerle@PS 309
### -----------------------------------------------------------
15 beyerle@PS 310
for dir in $DIR_NOT_COPY; do
311
    mkdir $NEW/$dir
312
done
26 beyerle@PS 313
# we do not need this directories
314
rmdir $NEW/livecd
315
# if not yet existing, create
316
mkdir -p $NEW/srv
317
mkdir -p $NEW/selinux
15 beyerle@PS 318
 
319
 
320
### copy back original files
16 beyerle@PS 321
### -----------------------------------------------------------
15 beyerle@PS 322
echo -n "Restore original files ... " 
323
for file in $FILES_RESTORE; do
324
    [ -r $NEW/${file}.ori ] && cp -a $NEW/${file}.ori $NEW/${file} 
325
done
326
echo "done."; echo
327
 
328
 
16 beyerle@PS 329
### define kernel version
330
### -----------------------------------------------------------
331
rpm --quiet -q kernel     && UP_installed=true
332
rpm --quiet -q kernel-smp && SMP_installed=true
333
[ $UP_installed ]  && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel 2>/dev/null )
334
[ $SMP_installed ] && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel-smp  2>/dev/null )
335
if [ ! $KERNEL_VERSION ]; then
336
    echo "ERROR: Kernel version could not be determined - installation failed"; echo
21 beyerle@PS 337
    exit_now 1
16 beyerle@PS 338
fi    
15 beyerle@PS 339
 
18 beyerle@PS 340
 
22 beyerle@PS 341
 
24 beyerle@PS 342
if [ ! $NOGRUB ]; then
15 beyerle@PS 343
 
26 beyerle@PS 344
    ### Backup Master Boot Record MBR
345
    ### -----------------------------------------------------------
346
    if [ ! $NOGRUB ]; then
347
	# do we have already a backup?
348
	MBR_FILENAME="MBR$( echo $MBR_DEV | tr / _ ).bak"
349
	if [ ! -e /tmp/$MBR_FILENAME ]; then
350
	    echo "Backup Master Boot Record (MBR) of $MBR_DEV ..."
351
	    dd if=$MBR_DEV of=/tmp/$MBR_FILENAME bs=512 count=1
352
	fi
353
	cp -a /tmp/$MBR_FILENAME $NEW/$MBR_FILENAME
354
	echo "MBR saved as $MBR_FILENAME on $INSTALL_PART and on /tmp"
355
	echo
356
    fi
357
 
358
 
24 beyerle@PS 359
    ### install grub
360
    ### -----------------------------------------------------------
26 beyerle@PS 361
    echo "Run grub-install ... "
24 beyerle@PS 362
    mkdir -p $NEW/boot/grub
363
    if [ $FLOPPY ]; then
364
	grub-install --root-directory=$NEW $MBR_DEV
365
    else
366
	grub-install --no-floppy --root-directory=$NEW $MBR_DEV
367
    fi
368
    echo "done."; echo
15 beyerle@PS 369
 
370
 
24 beyerle@PS 371
    ### check for device.map file 
372
    ### -----------------------------------------------------------
373
    DEVICE_MAP=$NEW/boot/grub/device.map
374
    if [ ! -e $NEW/boot/grub/device.map ]; then
375
	echo "ERROR: $NEW/boot/grub/device.map not found"
376
	exit_now 1
377
    fi
15 beyerle@PS 378
 
22 beyerle@PS 379
 
24 beyerle@PS 380
    ### convert dev syntax to grub syntax
381
    ### -----------------------------------------------------------
382
    GRUB_INSTALL_DEV=$( grep $INSTALL_DEV $DEVICE_MAP | awk '{ print $1 }' )
383
    GRUB_ROOT_PART=$( echo "$GRUB_INSTALL_DEV" | sed "s%)$%,`expr $INSTALL_PART_NR - 1`)%" )
22 beyerle@PS 384
 
15 beyerle@PS 385
 
24 beyerle@PS 386
    ### find active Windows partition
387
    ### -----------------------------------------------------------
388
    if [ ! $WIN_PART ]; then
389
        # try to find active Windows partition
390
	WIN_PART=$( fdisk -l 2>/dev/null | awk '{ if ($2 == "*" && $7 ~ "NTFS") print $1 }' | head -1 )
391
    fi
392
 
393
    if [ $WIN_PART ]; then
394
	WIN_installed=true
395
	WIN_DISK=$( echo "$WIN_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
396
	WIN_PART_NR=$( echo "$WIN_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
397
        # convert dev syntax to grub syntax
398
	GRUB_WIN_DEV=$( grep $WIN_DISK $DEVICE_MAP | awk '{ print $1 }' )
399
	GRUB_WIN_PART=$( echo "$GRUB_WIN_DEV" | sed "s%)$%,`expr $WIN_PART_NR - 1`)%" )
400
 
401
        # $GRUB_WIN_PART should be something like (hd0,0)
402
	echo "Found active Windows partition ( $WIN_PART = $GRUB_WIN_PART )" 
403
	echo "Will add entry for Windows in GRUB."
404
	echo
405
    fi
406
 
407
 
408
    ### create grub.conf file
409
    ### -----------------------------------------------------------
26 beyerle@PS 410
    echo "Create grub.conf ..."
24 beyerle@PS 411
 
412
    cat > $NEW/boot/grub/grub.conf <<EOF
15 beyerle@PS 413
# grub.conf generated by $SCRIPTNAME
414
default=0
415
timeout=5
416
splashimage=$GRUB_ROOT_PART/boot/grub/splash.xpm.gz
417
#hiddenmenu
16 beyerle@PS 418
EOF
419
 
24 beyerle@PS 420
    if [ $UP_installed ]; then
26 beyerle@PS 421
	echo "Add entry for UP kernel into grub.conf"
24 beyerle@PS 422
	cat >> $NEW/boot/grub/grub.conf <<EOF
16 beyerle@PS 423
title Scientific Linux (${KERNEL_VERSION})
15 beyerle@PS 424
        root $GRUB_ROOT_PART
425
	kernel /boot/vmlinuz-$KERNEL_VERSION ro root=$INSTALL_PART
426
	initrd /boot/initrd-$KERNEL_VERSION.img
16 beyerle@PS 427
EOF
24 beyerle@PS 428
    fi
16 beyerle@PS 429
 
24 beyerle@PS 430
    if [ $SMP_installed ]; then
26 beyerle@PS 431
	echo "Add entry for SMP kernel into grub.conf"
24 beyerle@PS 432
	cat >> $NEW/boot/grub/grub.conf <<EOF
16 beyerle@PS 433
title Scientific Linux (${KERNEL_VERSION}smp)
434
        root $GRUB_ROOT_PART
435
	kernel /boot/vmlinuz-${KERNEL_VERSION}smp ro root=$INSTALL_PART
436
	initrd /boot/initrd-${KERNEL_VERSION}smp.img
437
EOF
24 beyerle@PS 438
    fi
16 beyerle@PS 439
 
24 beyerle@PS 440
    if [ $WIN_installed ]; then
26 beyerle@PS 441
	echo "Add entry for Windows into grub.conf"
24 beyerle@PS 442
	cat >> $NEW/boot/grub/grub.conf <<EOF
15 beyerle@PS 443
title Windows
444
        rootnoverify $GRUB_WIN_PART
445
        chainloader +1
446
EOF
24 beyerle@PS 447
    fi
448
 
449
    chmod 600 $NEW/boot/grub/grub.conf
450
    ln -s ../boot/grub/grub.conf $NEW/etc/grub.conf
451
    ln -s ./grub.conf $NEW/boot/grub/menu.lst
452
    echo "done."; echo
453
 
16 beyerle@PS 454
fi
15 beyerle@PS 455
 
456
 
27 beyerle@PS 457
### install kernel and other files into /boot
16 beyerle@PS 458
### -----------------------------------------------------------
21 beyerle@PS 459
echo "Install kernel(s) ..."
15 beyerle@PS 460
 
16 beyerle@PS 461
[ -e /boot/vmlinuz ]      && BOOT_DIR=/boot
462
[ -e /boot/boot/vmlinuz ] && BOOT_DIR=/boot/boot
15 beyerle@PS 463
 
16 beyerle@PS 464
if [ ! $BOOT_DIR ]; then
465
    echo "ERROR: No kernel found - installation failed"; echo
21 beyerle@PS 466
    exit_now 1
16 beyerle@PS 467
fi
468
 
469
cp -a $BOOT_DIR/vmlinuz            $NEW/boot/vmlinuz-${KERNEL_VERSION}
470
cp -a $BOOT_DIR/vmlinuzs           $NEW/boot/vmlinuz-${KERNEL_VERSION}smp  2>/dev/null
471
cp -a $BOOT_DIR/System.map-*       $NEW/boot/
472
cp -a $BOOT_DIR/config-*           $NEW/boot/
26 beyerle@PS 473
cp -a $BOOT_DIR/symvers-*.gz       $NEW/boot/        2>/dev/null
16 beyerle@PS 474
cp -a $BOOT_DIR/grub/splash.xpm.gz $NEW/boot/grub/
26 beyerle@PS 475
cp -a $BOOT_DIR/message.ja         $NEW/boot/        2>/dev/null
476
cp -a $BOOT_DIR/message            $NEW/boot/        2>/dev/null
477
 
16 beyerle@PS 478
echo "done."; echo
479
 
480
 
21 beyerle@PS 481
### create /etc/fstab
16 beyerle@PS 482
### -----------------------------------------------------------
21 beyerle@PS 483
cat > $NEW/etc/fstab <<EOF
484
$INSTALL_PART         /                    ext3    defaults        1 1
485
devpts            /dev/pts             devpts  gid=5,mode=620  0 0
486
tmpfs             /dev/shm             tmpfs   defaults        0 0
487
proc              /proc                proc    defaults        0 0
488
sysfs             /sys                 sysfs   defaults        0 0
489
EOF
490
if [ $SWAP_PART ]; then
491
    echo "$SWAP_PART         swap                 swap    defaults        0 0" >> $NEW/etc/fstab
492
fi
493
 
494
 
495
### make initrd 
496
### (needs $NEW/etc/fstab to find correct modules for root filesystem !!)
497
### -----------------------------------------------------------
498
echo "Create initrd(s) ..."
22 beyerle@PS 499
# initrd should not be build on tmpfs (we take $NEW/tmp instead of /tmp)
500
sed -i "s|^TMPDIR=.*|TMPDIR=\"$NEW/tmp\"|" /usr/sbin/livecd-mkinitrd
501
 
16 beyerle@PS 502
if [ $UP_installed ]; then
21 beyerle@PS 503
    depmod -a ${KERNEL_VERSION}
22 beyerle@PS 504
    /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
21 beyerle@PS 505
                    $NEW//boot/initrd-${KERNEL_VERSION}.img ${KERNEL_VERSION}
18 beyerle@PS 506
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}.img ]; then
507
	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}.img"
21 beyerle@PS 508
	exit_now 1
18 beyerle@PS 509
    fi
16 beyerle@PS 510
fi
511
if [ $SMP_installed ]; then
21 beyerle@PS 512
    depmod -a ${KERNEL_VERSION}smp
22 beyerle@PS 513
    /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
21 beyerle@PS 514
                    $NEW/boot/initrd-${KERNEL_VERSION}smp.img ${KERNEL_VERSION}smp
18 beyerle@PS 515
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}smp.img ]; then
516
	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}smp.img"
21 beyerle@PS 517
	exit_now 1
18 beyerle@PS 518
    fi
16 beyerle@PS 519
fi
520
echo "done."; echo
521
 
522
 
15 beyerle@PS 523
### remove LiveCD init.d scripts
16 beyerle@PS 524
### -----------------------------------------------------------
525
for file in $LIVECD_INIT_SCRIPTS; do
526
    rm -f $NEW/etc/init.d/$file
527
    for n in 0 1 2 3 4 5 6; do
528
	rm -f $NEW/etc/rc.d/rc${n}.d/*$file
529
    done
15 beyerle@PS 530
done
531
 
16 beyerle@PS 532
 
533
### restore cronjobs
534
### -----------------------------------------------------------
26 beyerle@PS 535
mv $NEW/etc/cron_backup/sysstat $NEW/etc/cron.d/ 2>/dev/null
536
mv $NEW/etc/cron_backup/00-makewhatis.cron.weekly $NEW/etc/cron.weekly/00-makewhatis.cron 2>/dev/null
537
mv $NEW/etc/cron_backup/* $NEW/etc/cron.daily/
16 beyerle@PS 538
 
539
 
18 beyerle@PS 540
### turn on kudzu again
541
### -----------------------------------------------------------
26 beyerle@PS 542
chroot $NEW chkconfig kudzu on
18 beyerle@PS 543
 
544
 
15 beyerle@PS 545
### umount $INSTALL_PART
16 beyerle@PS 546
### -----------------------------------------------------------
547
umount $INSTALL_PART
15 beyerle@PS 548
 
22 beyerle@PS 549
 
550
### print summary
551
### -----------------------------------------------------------
26 beyerle@PS 552
echo                     "--------------------------------------------------------------"
553
echo                     "  LiveCD installed on partition $INSTALL_PART"
554
[ "$SWAP_PART" ] && echo "  Partition $SWAP_PART will be used as swap partition"
22 beyerle@PS 555
echo
26 beyerle@PS 556
[ ! $NOGRUB ]    && echo "  GRUB installed in Master Boot Record (MBR) of $MBR_DEV."
557
[ ! $NOGRUB ]    && echo "  MBR saved as $MBR_FILENAME on $INSTALL_PART and on /tmp"
558
[ ! $NOGRUB ]    && echo "  If you have to restore MBR, execute under Linux:"
559
[ ! $NOGRUB ]    && echo "  # dd if=$MBR_FILENAME of=$MBR_DEV bs=512 count=1"
560
echo 
561
[ $WIN_PART ]    && echo "  Entry created in grub.conf for Windows partition $WIN_PART"
562
echo                     "--------------------------------------------------------------"
563
echo                     "End of $SCRIPTNAME"
564
echo