Subversion Repositories livecd

Rev

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