Subversion Repositories livecd

Rev

Rev 27 | 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
 
28 beyerle@PS 172
### display fdisk -l
173
### -----------------------------------------------------------
174
echo "Output of 'fdisk -l' ..."
175
fdisk -l
176
echo
177
 
178
 
22 beyerle@PS 179
### test if $INSTALL_PART is defined and exists
180
### -----------------------------------------------------------
181
if [ ! $INSTALL_PART ]; then
182
    echo "No partition defined for installation"
183
    echo "Please see '$SCRIPTNAME -h'."; echo
184
    exit_now 1
185
fi
186
 
187
 
15 beyerle@PS 188
### test if MBR_DEV is given
16 beyerle@PS 189
### -----------------------------------------------------------
190
if [ ! $NOGRUB ]; then
191
    if [ ! $MBR_DEV ]; then
18 beyerle@PS 192
	echo "No MBR device defined."
16 beyerle@PS 193
	echo "Please see '$SCRIPTNAME -h'."; echo
21 beyerle@PS 194
	exit_now 1
16 beyerle@PS 195
    fi
15 beyerle@PS 196
fi
197
 
16 beyerle@PS 198
 
15 beyerle@PS 199
### test if $INSTALL_PART exists
16 beyerle@PS 200
### -----------------------------------------------------------
15 beyerle@PS 201
fdisk -l | cut -d" " -f1 | grep -q "^${INSTALL_PART}$"
202
if [ "$?" != "0" ]; then
28 beyerle@PS 203
    echo "Partition $INSTALL_PART not found! See 'fdisk -l'"
204
    echo "or you have to reboot first to make the partition table active"; echo
21 beyerle@PS 205
    exit_now 1
15 beyerle@PS 206
fi
207
 
16 beyerle@PS 208
 
15 beyerle@PS 209
### set $INSTALL_DEV (eg. /dev/sda)
16 beyerle@PS 210
### -----------------------------------------------------------
15 beyerle@PS 211
INSTALL_DEV=$( echo "$INSTALL_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
212
INSTALL_PART_NR=$( echo "$INSTALL_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
213
 
214
 
215
### test if $SWAP_PART exists
16 beyerle@PS 216
### -----------------------------------------------------------
15 beyerle@PS 217
if [ $SWAP_PART ]; then
218
    fdisk -l | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
219
    if [ "$?" != "0" ]; then
28 beyerle@PS 220
	echo "Swap partition $SWAP_PART not found! (see 'fdisk -l')"
221
	echo "Or you have to reboot first to make the partition table active"; echo
21 beyerle@PS 222
	exit_now 1
15 beyerle@PS 223
    fi
224
    fdisk -l | grep "Linux swap" | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
225
    if [ "$?" != "0" ]; then
28 beyerle@PS 226
	echo "Partition $SWAP_PART is not a Linux swap partition! (see 'fdisk -l')"
227
	echo "Use fdisk to create a Linux swap partition!"
228
	echo "You have to reboot first to make the partition table active"; echo
21 beyerle@PS 229
	exit_now 1
15 beyerle@PS 230
    fi
231
fi
232
 
233
 
28 beyerle@PS 234
 ### print warning
16 beyerle@PS 235
### -----------------------------------------------------------
26 beyerle@PS 236
echo                     "------------------------------------------------------------"
237
echo                     "   LiveCD will be installed on partition $INSTALL_PART"
15 beyerle@PS 238
[ "$SWAP_PART" ] && echo " Partition $SWAP_PART will be used as swap partition."
26 beyerle@PS 239
[ ! $NOGRUB ]    && echo " GRUB will be installed in Master Boot Record of $MBR_DEV"
240
echo                     "       !! All data on $INSTALL_PART will be lost !!"
241
echo                     "------------------------------------------------------------"
15 beyerle@PS 242
echo
16 beyerle@PS 243
 
15 beyerle@PS 244
 
26 beyerle@PS 245
### continue?
16 beyerle@PS 246
### -----------------------------------------------------------
15 beyerle@PS 247
if [ ! $YES ]; then
248
    echo -n "Continue (y/N)? "
18 beyerle@PS 249
    read key
15 beyerle@PS 250
    echo
21 beyerle@PS 251
    [ "$key" != "y" ] && exit_now 0
15 beyerle@PS 252
fi
253
 
254
 
26 beyerle@PS 255
### format $SWAP_PART
21 beyerle@PS 256
### -----------------------------------------------------------
26 beyerle@PS 257
if [ $SWAP_PART ]; then
258
    echo "Make swap on $SWAP_PART ..."
259
    mkswap $SWAP_PART
24 beyerle@PS 260
    echo
261
fi
21 beyerle@PS 262
 
263
 
15 beyerle@PS 264
### format $INSTALL_PART
16 beyerle@PS 265
### -----------------------------------------------------------
15 beyerle@PS 266
echo -n "Format $INSTALL_PART, please wait ... " 
21 beyerle@PS 267
mkfs.ext3 -q $INSTALL_PART || exit_now 1
15 beyerle@PS 268
echo "done."; echo
269
 
270
 
271
### mount $INSTALL_PART
16 beyerle@PS 272
### -----------------------------------------------------------
15 beyerle@PS 273
echo -n "Try to mount $INSTALL_PART to $NEW ... "
274
mkdir -p $NEW
21 beyerle@PS 275
mount $INSTALL_PART $NEW || exit_now 1
15 beyerle@PS 276
echo "done."; echo
277
 
278
 
279
### copy root dirs
16 beyerle@PS 280
### -----------------------------------------------------------
26 beyerle@PS 281
echo "Copy Live System to $INSTALL_PART ..."
15 beyerle@PS 282
root_dirs=$( ls / )
283
for dir in $root_dirs; do
284
    # check if dir is not in $DIR_NOT_COPY
285
    do_not_copy=""
286
    for not_dir in $DIR_NOT_COPY; do
287
	if [ "$not_dir" = "/$dir" ]; then 
288
	    do_not_copy="yes"
289
	    break
290
	fi
291
    done
292
    # do not copy links
293
    [ -L /$dir ] && do_not_copy="yes"
294
 
21 beyerle@PS 295
    fail=""
15 beyerle@PS 296
    if [ ! $do_not_copy ]; then
297
	echo -n "  * Copy  /$dir ... "
21 beyerle@PS 298
	cp -a /$dir $NEW || fail=true
15 beyerle@PS 299
	echo "done."
300
    fi
301
done
302
echo
21 beyerle@PS 303
if [ $fail ]; then
304
    echo "ERROR: Not everything was copied to $INSTALL_PART"
305
    exit_now 1
306
fi
15 beyerle@PS 307
 
308
 
16 beyerle@PS 309
### move /usr/opt back to /opt
310
### -----------------------------------------------------------
15 beyerle@PS 311
if [ -d $NEW/usr/opt ]; then
312
    echo -n "Move /opt back ... "
313
    mv $NEW/usr/opt $NEW/
314
    echo "done."; echo
315
fi
316
 
317
 
318
### create dirs which were not copied
16 beyerle@PS 319
### -----------------------------------------------------------
15 beyerle@PS 320
for dir in $DIR_NOT_COPY; do
321
    mkdir $NEW/$dir
322
done
26 beyerle@PS 323
# we do not need this directories
324
rmdir $NEW/livecd
325
# if not yet existing, create
326
mkdir -p $NEW/srv
327
mkdir -p $NEW/selinux
15 beyerle@PS 328
 
329
 
330
### copy back original files
16 beyerle@PS 331
### -----------------------------------------------------------
15 beyerle@PS 332
echo -n "Restore original files ... " 
333
for file in $FILES_RESTORE; do
28 beyerle@PS 334
    [ -r $NEW/${file}.ori ] && mv -f $NEW/${file}.ori $NEW/${file} 
15 beyerle@PS 335
done
336
echo "done."; echo
337
 
338
 
16 beyerle@PS 339
### define kernel version
340
### -----------------------------------------------------------
341
rpm --quiet -q kernel     && UP_installed=true
342
rpm --quiet -q kernel-smp && SMP_installed=true
343
[ $UP_installed ]  && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel 2>/dev/null )
344
[ $SMP_installed ] && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel-smp  2>/dev/null )
345
if [ ! $KERNEL_VERSION ]; then
346
    echo "ERROR: Kernel version could not be determined - installation failed"; echo
21 beyerle@PS 347
    exit_now 1
16 beyerle@PS 348
fi    
15 beyerle@PS 349
 
18 beyerle@PS 350
 
22 beyerle@PS 351
 
24 beyerle@PS 352
if [ ! $NOGRUB ]; then
15 beyerle@PS 353
 
26 beyerle@PS 354
    ### Backup Master Boot Record MBR
355
    ### -----------------------------------------------------------
356
    if [ ! $NOGRUB ]; then
357
	# do we have already a backup?
358
	MBR_FILENAME="MBR$( echo $MBR_DEV | tr / _ ).bak"
359
	if [ ! -e /tmp/$MBR_FILENAME ]; then
360
	    echo "Backup Master Boot Record (MBR) of $MBR_DEV ..."
361
	    dd if=$MBR_DEV of=/tmp/$MBR_FILENAME bs=512 count=1
362
	fi
363
	cp -a /tmp/$MBR_FILENAME $NEW/$MBR_FILENAME
364
	echo "MBR saved as $MBR_FILENAME on $INSTALL_PART and on /tmp"
365
	echo
366
    fi
367
 
368
 
24 beyerle@PS 369
    ### install grub
370
    ### -----------------------------------------------------------
26 beyerle@PS 371
    echo "Run grub-install ... "
24 beyerle@PS 372
    mkdir -p $NEW/boot/grub
373
    if [ $FLOPPY ]; then
374
	grub-install --root-directory=$NEW $MBR_DEV
375
    else
376
	grub-install --no-floppy --root-directory=$NEW $MBR_DEV
377
    fi
378
    echo "done."; echo
15 beyerle@PS 379
 
380
 
24 beyerle@PS 381
    ### check for device.map file 
382
    ### -----------------------------------------------------------
383
    DEVICE_MAP=$NEW/boot/grub/device.map
384
    if [ ! -e $NEW/boot/grub/device.map ]; then
385
	echo "ERROR: $NEW/boot/grub/device.map not found"
386
	exit_now 1
387
    fi
15 beyerle@PS 388
 
22 beyerle@PS 389
 
24 beyerle@PS 390
    ### convert dev syntax to grub syntax
391
    ### -----------------------------------------------------------
392
    GRUB_INSTALL_DEV=$( grep $INSTALL_DEV $DEVICE_MAP | awk '{ print $1 }' )
393
    GRUB_ROOT_PART=$( echo "$GRUB_INSTALL_DEV" | sed "s%)$%,`expr $INSTALL_PART_NR - 1`)%" )
22 beyerle@PS 394
 
15 beyerle@PS 395
 
24 beyerle@PS 396
    ### find active Windows partition
397
    ### -----------------------------------------------------------
398
    if [ ! $WIN_PART ]; then
399
        # try to find active Windows partition
400
	WIN_PART=$( fdisk -l 2>/dev/null | awk '{ if ($2 == "*" && $7 ~ "NTFS") print $1 }' | head -1 )
401
    fi
402
 
403
    if [ $WIN_PART ]; then
404
	WIN_installed=true
405
	WIN_DISK=$( echo "$WIN_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
406
	WIN_PART_NR=$( echo "$WIN_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
407
        # convert dev syntax to grub syntax
408
	GRUB_WIN_DEV=$( grep $WIN_DISK $DEVICE_MAP | awk '{ print $1 }' )
409
	GRUB_WIN_PART=$( echo "$GRUB_WIN_DEV" | sed "s%)$%,`expr $WIN_PART_NR - 1`)%" )
410
 
411
        # $GRUB_WIN_PART should be something like (hd0,0)
412
	echo "Found active Windows partition ( $WIN_PART = $GRUB_WIN_PART )" 
413
	echo "Will add entry for Windows in GRUB."
414
	echo
415
    fi
416
 
417
 
418
    ### create grub.conf file
419
    ### -----------------------------------------------------------
26 beyerle@PS 420
    echo "Create grub.conf ..."
24 beyerle@PS 421
 
28 beyerle@PS 422
    TITLE="Linux"
423
    [ -e $NEW//etc/redhat-release ] && TITLE=$( cat $NEW/etc/redhat-release )
424
 
24 beyerle@PS 425
    cat > $NEW/boot/grub/grub.conf <<EOF
15 beyerle@PS 426
# grub.conf generated by $SCRIPTNAME
427
default=0
428
timeout=5
429
splashimage=$GRUB_ROOT_PART/boot/grub/splash.xpm.gz
430
#hiddenmenu
16 beyerle@PS 431
EOF
432
 
24 beyerle@PS 433
    if [ $UP_installed ]; then
26 beyerle@PS 434
	echo "Add entry for UP kernel into grub.conf"
24 beyerle@PS 435
	cat >> $NEW/boot/grub/grub.conf <<EOF
28 beyerle@PS 436
title $TITLE (${KERNEL_VERSION})
15 beyerle@PS 437
        root $GRUB_ROOT_PART
438
	kernel /boot/vmlinuz-$KERNEL_VERSION ro root=$INSTALL_PART
439
	initrd /boot/initrd-$KERNEL_VERSION.img
16 beyerle@PS 440
EOF
24 beyerle@PS 441
    fi
16 beyerle@PS 442
 
24 beyerle@PS 443
    if [ $SMP_installed ]; then
26 beyerle@PS 444
	echo "Add entry for SMP kernel into grub.conf"
24 beyerle@PS 445
	cat >> $NEW/boot/grub/grub.conf <<EOF
28 beyerle@PS 446
title $TITLE (${KERNEL_VERSION}smp)
16 beyerle@PS 447
        root $GRUB_ROOT_PART
448
	kernel /boot/vmlinuz-${KERNEL_VERSION}smp ro root=$INSTALL_PART
449
	initrd /boot/initrd-${KERNEL_VERSION}smp.img
450
EOF
24 beyerle@PS 451
    fi
16 beyerle@PS 452
 
24 beyerle@PS 453
    if [ $WIN_installed ]; then
26 beyerle@PS 454
	echo "Add entry for Windows into grub.conf"
24 beyerle@PS 455
	cat >> $NEW/boot/grub/grub.conf <<EOF
15 beyerle@PS 456
title Windows
457
        rootnoverify $GRUB_WIN_PART
458
        chainloader +1
459
EOF
24 beyerle@PS 460
    fi
461
 
462
    chmod 600 $NEW/boot/grub/grub.conf
463
    ln -s ../boot/grub/grub.conf $NEW/etc/grub.conf
464
    ln -s ./grub.conf $NEW/boot/grub/menu.lst
465
    echo "done."; echo
466
 
16 beyerle@PS 467
fi
15 beyerle@PS 468
 
469
 
27 beyerle@PS 470
### install kernel and other files into /boot
16 beyerle@PS 471
### -----------------------------------------------------------
21 beyerle@PS 472
echo "Install kernel(s) ..."
15 beyerle@PS 473
 
16 beyerle@PS 474
[ -e /boot/vmlinuz ]      && BOOT_DIR=/boot
475
[ -e /boot/boot/vmlinuz ] && BOOT_DIR=/boot/boot
15 beyerle@PS 476
 
16 beyerle@PS 477
if [ ! $BOOT_DIR ]; then
478
    echo "ERROR: No kernel found - installation failed"; echo
21 beyerle@PS 479
    exit_now 1
16 beyerle@PS 480
fi
481
 
482
cp -a $BOOT_DIR/vmlinuz            $NEW/boot/vmlinuz-${KERNEL_VERSION}
483
cp -a $BOOT_DIR/vmlinuzs           $NEW/boot/vmlinuz-${KERNEL_VERSION}smp  2>/dev/null
484
cp -a $BOOT_DIR/System.map-*       $NEW/boot/
485
cp -a $BOOT_DIR/config-*           $NEW/boot/
26 beyerle@PS 486
cp -a $BOOT_DIR/symvers-*.gz       $NEW/boot/        2>/dev/null
16 beyerle@PS 487
cp -a $BOOT_DIR/grub/splash.xpm.gz $NEW/boot/grub/
26 beyerle@PS 488
cp -a $BOOT_DIR/message.ja         $NEW/boot/        2>/dev/null
489
cp -a $BOOT_DIR/message            $NEW/boot/        2>/dev/null
490
 
16 beyerle@PS 491
echo "done."; echo
492
 
493
 
21 beyerle@PS 494
### create /etc/fstab
16 beyerle@PS 495
### -----------------------------------------------------------
21 beyerle@PS 496
cat > $NEW/etc/fstab <<EOF
497
$INSTALL_PART         /                    ext3    defaults        1 1
498
devpts            /dev/pts             devpts  gid=5,mode=620  0 0
499
tmpfs             /dev/shm             tmpfs   defaults        0 0
500
proc              /proc                proc    defaults        0 0
501
sysfs             /sys                 sysfs   defaults        0 0
502
EOF
503
if [ $SWAP_PART ]; then
504
    echo "$SWAP_PART         swap                 swap    defaults        0 0" >> $NEW/etc/fstab
505
fi
506
 
507
 
508
### make initrd 
509
### (needs $NEW/etc/fstab to find correct modules for root filesystem !!)
510
### -----------------------------------------------------------
511
echo "Create initrd(s) ..."
22 beyerle@PS 512
# initrd should not be build on tmpfs (we take $NEW/tmp instead of /tmp)
513
sed -i "s|^TMPDIR=.*|TMPDIR=\"$NEW/tmp\"|" /usr/sbin/livecd-mkinitrd
514
 
16 beyerle@PS 515
if [ $UP_installed ]; then
21 beyerle@PS 516
    depmod -a ${KERNEL_VERSION}
22 beyerle@PS 517
    /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
21 beyerle@PS 518
                    $NEW//boot/initrd-${KERNEL_VERSION}.img ${KERNEL_VERSION}
18 beyerle@PS 519
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}.img ]; then
520
	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}.img"
21 beyerle@PS 521
	exit_now 1
18 beyerle@PS 522
    fi
16 beyerle@PS 523
fi
524
if [ $SMP_installed ]; then
21 beyerle@PS 525
    depmod -a ${KERNEL_VERSION}smp
22 beyerle@PS 526
    /usr/sbin/livecd-mkinitrd --fstab=$NEW/etc/fstab \
21 beyerle@PS 527
                    $NEW/boot/initrd-${KERNEL_VERSION}smp.img ${KERNEL_VERSION}smp
18 beyerle@PS 528
    if [ ! -e $NEW/boot/initrd-${KERNEL_VERSION}smp.img ]; then
529
	echo "ERROR: Failed to create $NEW/boot/initrd-${KERNEL_VERSION}smp.img"
21 beyerle@PS 530
	exit_now 1
18 beyerle@PS 531
    fi
16 beyerle@PS 532
fi
533
echo "done."; echo
534
 
535
 
15 beyerle@PS 536
### remove LiveCD init.d scripts
16 beyerle@PS 537
### -----------------------------------------------------------
538
for file in $LIVECD_INIT_SCRIPTS; do
539
    rm -f $NEW/etc/init.d/$file
540
    for n in 0 1 2 3 4 5 6; do
541
	rm -f $NEW/etc/rc.d/rc${n}.d/*$file
542
    done
15 beyerle@PS 543
done
544
 
16 beyerle@PS 545
 
546
### restore cronjobs
547
### -----------------------------------------------------------
26 beyerle@PS 548
mv $NEW/etc/cron_backup/sysstat $NEW/etc/cron.d/ 2>/dev/null
549
mv $NEW/etc/cron_backup/00-makewhatis.cron.weekly $NEW/etc/cron.weekly/00-makewhatis.cron 2>/dev/null
550
mv $NEW/etc/cron_backup/* $NEW/etc/cron.daily/
16 beyerle@PS 551
 
552
 
18 beyerle@PS 553
### turn on kudzu again
554
### -----------------------------------------------------------
26 beyerle@PS 555
chroot $NEW chkconfig kudzu on
18 beyerle@PS 556
 
557
 
15 beyerle@PS 558
### umount $INSTALL_PART
16 beyerle@PS 559
### -----------------------------------------------------------
560
umount $INSTALL_PART
15 beyerle@PS 561
 
22 beyerle@PS 562
 
563
### print summary
564
### -----------------------------------------------------------
26 beyerle@PS 565
echo                     "--------------------------------------------------------------"
566
echo                     "  LiveCD installed on partition $INSTALL_PART"
567
[ "$SWAP_PART" ] && echo "  Partition $SWAP_PART will be used as swap partition"
22 beyerle@PS 568
echo
28 beyerle@PS 569
[ ! $NOGRUB ]    && echo "  GRUB installed in Master Boot Record (MBR) of $MBR_DEV"
570
[ ! $NOGRUB ]    && echo "  MBR saved as $MBR_FILENAME on $INSTALL_PART and in /tmp"
26 beyerle@PS 571
[ ! $NOGRUB ]    && echo "  If you have to restore MBR, execute under Linux:"
572
[ ! $NOGRUB ]    && echo "  # dd if=$MBR_FILENAME of=$MBR_DEV bs=512 count=1"
573
echo 
574
[ $WIN_PART ]    && echo "  Entry created in grub.conf for Windows partition $WIN_PART"
575
echo                     "--------------------------------------------------------------"
576
echo                     "End of $SCRIPTNAME"
577
echo