Subversion Repositories livecd

Rev

Rev 22 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 22 Rev 24
Line 122... Line 122...
122
            usage; exit_now;;
122
            usage; exit_now;;
123
 
123
 
124
       --help)
124
       --help)
125
            usage; exit_now;;
125
            usage; exit_now;;
126
 
126
 
127
       -swap)
127
       -swap*)
128
           if echo $1 | grep -q '=' ; then
128
           if echo $1 | grep -q '=' ; then
129
	       SWAP_PART=$( echo $1 | sed 's/^-swap=//' )
129
	       SWAP_PART=$( echo $1 | sed 's/^-swap=//' )
130
	   else
130
	   else
131
	       shift
131
	       shift
132
               SWAP_PART=$2
132
               SWAP_PART=$1
133
	   fi
133
	   fi
134
	   shift; continue;;
134
	   shift; continue;;
135
 
135
 
136
       -mbr)
136
       -mbr*)
137
           if echo $1 | grep -q '=' ; then
137
           if echo $1 | grep -q '=' ; then
138
	       MBR_DEV=$( echo $1 | sed 's/^-mbr=//' )
138
	       MBR_DEV=$( echo $1 | sed 's/^-mbr=//' )
139
	   else
139
	   else
140
	       shift
140
	       shift
141
               MBR_DEV=$2
141
               MBR_DEV=$1
142
	   fi
142
	   fi
143
	   shift; continue;;
143
	   shift; continue;;
144
 
144
 
145
       -win)
145
       -win*)
146
           if echo $1 | grep -q '=' ; then
146
           if echo $1 | grep -q '=' ; then
147
	       WIN_PART=$( echo $1 | sed 's/^-win=//' )
147
	       WIN_PART=$( echo $1 | sed 's/^-win=//' )
148
	   else
148
	   else
149
	       shift
149
	       shift
150
               WIN_PART=$2
150
               WIN_PART=$1
151
	   fi
151
	   fi
152
	   shift; continue;;
152
	   shift; continue;;
153
 
153
 
154
       -nogrub)
154
       -nogrub)
155
            NOGRUB=$1; shift; continue;;
155
            NOGRUB=$1; shift; continue;;
Line 246... Line 246...
246
 
246
 
247
### Backup MBR
247
### Backup MBR
248
### -----------------------------------------------------------
248
### -----------------------------------------------------------
249
### to do !!!!!!!!!!
249
### to do !!!!!!!!!!
250
###
250
###
-
 
251
if [ ! $NOGRUB ]; then
-
 
252
    echo
-
 
253
fi
251
 
254
 
252
 
255
 
253
### format $INSTALL_PART
256
### format $INSTALL_PART
254
### -----------------------------------------------------------
257
### -----------------------------------------------------------
255
echo -n "Format $INSTALL_PART, please wait ... " 
258
echo -n "Format $INSTALL_PART, please wait ... " 
Line 319... Line 322...
319
    [ -r $NEW/${file}.ori ] && cp -a $NEW/${file}.ori $NEW/${file} 
322
    [ -r $NEW/${file}.ori ] && cp -a $NEW/${file}.ori $NEW/${file} 
320
done
323
done
321
echo "done."; echo
324
echo "done."; echo
322
 
325
 
323
 
326
 
324
### do some mounts for chroot $NEW (no more needed)
-
 
325
### -----------------------------------------------------------
-
 
326
# mount --bind /dev $NEW/dev
-
 
327
# mount --bind /sys $NEW/sys 
-
 
328
# mount -t proc proc $NEW/proc
-
 
329
 
-
 
330
 
-
 
331
### install grub
-
 
332
### -----------------------------------------------------------
-
 
333
echo "Run grub-install: "; echo
-
 
334
mkdir -p $NEW/boot/grub
-
 
335
if [ $FLOPPY ]; then
-
 
336
    grub-install --root-directory=$NEW $MBR_DEV
-
 
337
else
-
 
338
    grub-install --no-floppy --root-directory=$NEW $MBR_DEV
-
 
339
fi
-
 
340
echo "done."; echo
-
 
341
 
-
 
342
 
327
 
343
### define kernel version
328
### define kernel version
344
### -----------------------------------------------------------
329
### -----------------------------------------------------------
345
rpm --quiet -q kernel     && UP_installed=true
330
rpm --quiet -q kernel     && UP_installed=true
346
rpm --quiet -q kernel-smp && SMP_installed=true
331
rpm --quiet -q kernel-smp && SMP_installed=true
Line 350... Line 335...
350
    echo "ERROR: Kernel version could not be determined - installation failed"; echo
335
    echo "ERROR: Kernel version could not be determined - installation failed"; echo
351
    exit_now 1
336
    exit_now 1
352
fi    
337
fi    
353
 
338
 
354
 
339
 
355
### check for device.map file 
-
 
356
### -----------------------------------------------------------
-
 
357
DEVICE_MAP=$NEW/boot/grub/device.map
-
 
358
if [ ! -e $NEW/boot/grub/device.map ]; then
-
 
359
    echo "ERROR: $NEW/boot/grub/device.map not found"
-
 
360
    exit_now 1
-
 
361
fi
-
 
362
 
340
 
363
 
341
 
364
### convert dev syntax to grub syntax
342
if [ ! $NOGRUB ]; then
365
### -----------------------------------------------------------
-
 
366
GRUB_INSTALL_DEV=$( grep $INSTALL_DEV $DEVICE_MAP | awk '{ print $1 }' )
-
 
367
GRUB_ROOT_PART=$( echo "$GRUB_INSTALL_DEV" | sed "s%)$%,`expr $INSTALL_PART_NR - 1`)%" )
-
 
368
 
343
 
-
 
344
    ### install grub
-
 
345
    ### -----------------------------------------------------------
-
 
346
    echo "Run grub-install: "; echo
-
 
347
    mkdir -p $NEW/boot/grub
-
 
348
    if [ $FLOPPY ]; then
-
 
349
	grub-install --root-directory=$NEW $MBR_DEV
-
 
350
    else
-
 
351
	grub-install --no-floppy --root-directory=$NEW $MBR_DEV
-
 
352
    fi
-
 
353
    echo "done."; echo
369
 
354
 
370
### find active Windows partition
-
 
371
### -----------------------------------------------------------
-
 
372
if [ ! $WIN_PART ]; then
-
 
373
    # try to find active Windows partition
-
 
374
    WIN_PART=$( fdisk -l 2>/dev/null | awk '{ if ($2 == "*" && $7 ~ "NTFS") print $1 }' | head -1 )
-
 
375
fi
-
 
376
 
355
 
377
if [ $WIN_PART ]; then
-
 
378
    WIN_installed=true
356
    ### check for device.map file 
379
    WIN_DISK=$( echo "$WIN_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
357
    ### -----------------------------------------------------------
380
    WIN_PART_NR=$( echo "$WIN_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
-
 
381
    # convert dev syntax to grub syntax
358
    DEVICE_MAP=$NEW/boot/grub/device.map
382
    GRUB_WIN_DEV=$( grep $WIN_DISK $DEVICE_MAP | awk '{ print $1 }' )
-
 
383
    GRUB_WIN_PART=$( echo "$GRUB_WIN_DEV" | sed "s%)$%,`expr $WIN_PART_NR - 1`)%" )
-
 
384
 
-
 
385
    # $GRUB_WIN_PART should be something like (hd0,0)
359
    if [ ! -e $NEW/boot/grub/device.map ]; then
386
    echo "Found active Windows partition ( $WIN_PART = $GRUB_WIN_PART )" 
-
 
387
    echo "Will add entry for Windows in GRUB."
360
	echo "ERROR: $NEW/boot/grub/device.map not found"
388
    echo
361
	exit_now 1
389
fi
362
    fi
390
 
363
 
391
 
364
 
-
 
365
    ### convert dev syntax to grub syntax
-
 
366
    ### -----------------------------------------------------------
-
 
367
    GRUB_INSTALL_DEV=$( grep $INSTALL_DEV $DEVICE_MAP | awk '{ print $1 }' )
-
 
368
    GRUB_ROOT_PART=$( echo "$GRUB_INSTALL_DEV" | sed "s%)$%,`expr $INSTALL_PART_NR - 1`)%" )
-
 
369
 
-
 
370
 
-
 
371
    ### find active Windows partition
-
 
372
    ### -----------------------------------------------------------
-
 
373
    if [ ! $WIN_PART ]; then
-
 
374
        # try to find active Windows partition
-
 
375
	WIN_PART=$( fdisk -l 2>/dev/null | awk '{ if ($2 == "*" && $7 ~ "NTFS") print $1 }' | head -1 )
-
 
376
    fi
-
 
377
 
-
 
378
    if [ $WIN_PART ]; then
-
 
379
	WIN_installed=true
-
 
380
	WIN_DISK=$( echo "$WIN_PART" | sed -e 's%\([sh]d[a-z]\)[0-9]*$%\1%' )
-
 
381
	WIN_PART_NR=$( echo "$WIN_PART" | sed -e 's%.*/[sh]d[a-z]\([0-9]*\)$%\1%' )
-
 
382
        # convert dev syntax to grub syntax
-
 
383
	GRUB_WIN_DEV=$( grep $WIN_DISK $DEVICE_MAP | awk '{ print $1 }' )
-
 
384
	GRUB_WIN_PART=$( echo "$GRUB_WIN_DEV" | sed "s%)$%,`expr $WIN_PART_NR - 1`)%" )
-
 
385
 
-
 
386
        # $GRUB_WIN_PART should be something like (hd0,0)
-
 
387
	echo "Found active Windows partition ( $WIN_PART = $GRUB_WIN_PART )" 
-
 
388
	echo "Will add entry for Windows in GRUB."
-
 
389
	echo
-
 
390
    fi
-
 
391
 
-
 
392
 
392
### create grub.conf file
393
    ### create grub.conf file
393
### -----------------------------------------------------------
394
    ### -----------------------------------------------------------
394
echo "Create grub.conf:"
395
    echo "Create grub.conf:"
395
 
396
 
396
cat > $NEW/boot/grub/grub.conf <<EOF
397
    cat > $NEW/boot/grub/grub.conf <<EOF
397
# grub.conf generated by $SCRIPTNAME
398
# grub.conf generated by $SCRIPTNAME
398
default=0
399
default=0
399
timeout=5
400
timeout=5
400
splashimage=$GRUB_ROOT_PART/boot/grub/splash.xpm.gz
401
splashimage=$GRUB_ROOT_PART/boot/grub/splash.xpm.gz
401
#hiddenmenu
402
#hiddenmenu
402
EOF
403
EOF
403
 
404
 
404
if [ $UP_installed ]; then
405
    if [ $UP_installed ]; then
405
    echo " Add entry for UP kernel into grub.conf"
406
	echo " Add entry for UP kernel into grub.conf"
406
    cat >> $NEW/boot/grub/grub.conf <<EOF
407
	cat >> $NEW/boot/grub/grub.conf <<EOF
407
title Scientific Linux (${KERNEL_VERSION})
408
title Scientific Linux (${KERNEL_VERSION})
408
        root $GRUB_ROOT_PART
409
        root $GRUB_ROOT_PART
409
	kernel /boot/vmlinuz-$KERNEL_VERSION ro root=$INSTALL_PART
410
	kernel /boot/vmlinuz-$KERNEL_VERSION ro root=$INSTALL_PART
410
	initrd /boot/initrd-$KERNEL_VERSION.img
411
	initrd /boot/initrd-$KERNEL_VERSION.img
411
EOF
412
EOF
412
fi
413
    fi
413
 
414
 
414
if [ $SMP_installed ]; then
415
    if [ $SMP_installed ]; then
415
    echo " Add entry for SMP kernel into grub.conf"
416
	echo " Add entry for SMP kernel into grub.conf"
416
    cat >> $NEW/boot/grub/grub.conf <<EOF
417
	cat >> $NEW/boot/grub/grub.conf <<EOF
417
title Scientific Linux (${KERNEL_VERSION}smp)
418
title Scientific Linux (${KERNEL_VERSION}smp)
418
        root $GRUB_ROOT_PART
419
        root $GRUB_ROOT_PART
419
	kernel /boot/vmlinuz-${KERNEL_VERSION}smp ro root=$INSTALL_PART
420
	kernel /boot/vmlinuz-${KERNEL_VERSION}smp ro root=$INSTALL_PART
420
	initrd /boot/initrd-${KERNEL_VERSION}smp.img
421
	initrd /boot/initrd-${KERNEL_VERSION}smp.img
421
EOF
422
EOF
422
fi
423
    fi
423
 
424
 
424
if [ $WIN_installed ]; then
425
    if [ $WIN_installed ]; then
425
    echo " Add entry for Windows into grub.conf"
426
	echo " Add entry for Windows into grub.conf"
426
    cat >> $NEW/boot/grub/grub.conf <<EOF
427
	cat >> $NEW/boot/grub/grub.conf <<EOF
427
title Windows
428
title Windows
428
        rootnoverify $GRUB_WIN_PART
429
        rootnoverify $GRUB_WIN_PART
429
        chainloader +1
430
        chainloader +1
430
EOF
431
EOF
431
fi
432
    fi
432
 
433
 
433
chmod 600 $NEW/boot/grub/grub.conf
434
    chmod 600 $NEW/boot/grub/grub.conf
434
ln -s ../boot/grub/grub.conf $NEW/etc/grub.conf
435
    ln -s ../boot/grub/grub.conf $NEW/etc/grub.conf
435
ln -s ./grub.conf $NEW/boot/grub/menu.lst
436
    ln -s ./grub.conf $NEW/boot/grub/menu.lst
436
echo "done."; echo
437
    echo "done."; echo
-
 
438
 
-
 
439
fi
437
 
440
 
438
 
441
 
439
### install kernel into /boot
442
### install kernel into /boot
440
### -----------------------------------------------------------
443
### -----------------------------------------------------------
441
echo "Install kernel(s) ..."
444
echo "Install kernel(s) ..."