Subversion Repositories livecd

Rev

Rev 24 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24 Rev 26
Line 63... Line 63...
63
 
63
 
64
   cat <<EOF
64
   cat <<EOF
65
   
65
   
66
  $SCRIPTNAME [OPTIONS] -mbr=[DEVICE] [PARTITION]
66
  $SCRIPTNAME [OPTIONS] -mbr=[DEVICE] [PARTITION]
67
 
67
 
68
    Installes LiveCD on PARTITION and the boot loader grub
68
    Installes LiveCD on PARTITION and the bootloader grub into 
69
    into the Master Boot Record (MBR) of DEVICE.
69
    the Master Boot Record (MBR) of DEVICE. The MBR will be 
-
 
70
    backed up to PARTITION.
70
 
71
 
71
  OPTIONS:
72
  OPTIONS:
72
 
73
 
73
    -h   --help         print this screen
74
    -h   --help         Print this screen
74
    -swap=[partition]   use [partition] as swap
75
    -swap=[partition]   Use [partition] as swap
75
    -win=[partition]    your active Windows partition. If not given, 
76
    -win=[partition]    Your active Windows partition. If not given, 
76
                        $SCRIPTNAME tries to find it
77
                        $SCRIPTNAME tries to find it
77
    -nogrub             do not install grub (leave MBR untouched) 
78
    -nogrub             Do not install grub. You have to install 
-
 
79
                        manually a bootloader (not recommended)
78
    -floppy             needed, if grub should be installed on floppy
80
    -floppy             Needed, if grub should be installed on floppy
79
    -y                  answer all questions with yes
81
    -y                  Answer all questions with yes
80
 
-
 
81
 
82
 
82
  Example:
83
  Example:
83
 
84
 
84
  $SCRIPTNAME -swap=/dev/sda3 -mbr=/dev/sda /dev/sda2
85
  $SCRIPTNAME -swap=/dev/sda3 -mbr=/dev/sda /dev/sda2
85
 
86
 
Line 211... Line 212...
211
	echo "Swap partition $SWAP_PART not found! (see 'disk -l')"; echo
212
	echo "Swap partition $SWAP_PART not found! (see 'disk -l')"; echo
212
	exit_now 1
213
	exit_now 1
213
    fi
214
    fi
214
    fdisk -l | grep "Linux swap" | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
215
    fdisk -l | grep "Linux swap" | cut -d" " -f1 | grep -q "^${SWAP_PART}$"
215
    if [ "$?" != "0" ]; then
216
    if [ "$?" != "0" ]; then
216
	echo "Partition $SWAP_PART is not a Linux swap partition! (see 'disk -l')"; echo
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
217
	exit_now 1
219
	exit_now 1
218
    fi
220
    fi
219
fi
221
fi
220
 
222
 
221
 
223
 
222
### print warning
224
### print warning
223
### -----------------------------------------------------------
225
### -----------------------------------------------------------
224
echo "-----------------------------------------------------------"
226
echo                     "------------------------------------------------------------"
225
echo "   LiveCD will be installed on partition $INSTALL_PART."
227
echo                     "   LiveCD will be installed on partition $INSTALL_PART"
226
[ "$SWAP_PART" ] && echo " Partition $SWAP_PART will be used as swap partition."
228
[ "$SWAP_PART" ] && echo " Partition $SWAP_PART will be used as swap partition."
227
 
-
 
228
echo
-
 
229
[ ! $NOGRUB ] && echo " !! Master Boot Record of $MBR_DEV will be overwritten !!"
229
[ ! $NOGRUB ]    && echo " GRUB will be installed in Master Boot Record of $MBR_DEV"
230
 
-
 
231
echo "     !! All data on $INSTALL_PART will be lost !!"
230
echo                     "       !! All data on $INSTALL_PART will be lost !!"
232
echo "-----------------------------------------------------------"
231
echo                     "------------------------------------------------------------"
233
echo
232
echo
234
 
233
 
235
 
234
 
236
### continue ?
235
### continue?
237
### -----------------------------------------------------------
236
### -----------------------------------------------------------
Line 239... Line 238...
239
    echo -n "Continue (y/N)? "
238
    echo -n "Continue (y/N)? "
240
    read key
239
    read key
241
    echo
240
    echo
242
    [ "$key" != "y" ] && exit_now 0
241
    [ "$key" != "y" ] && exit_now 0
243
fi
242
fi
244
echo
-
 
245
 
243
 
246
 
244
 
247
### Backup MBR
245
### format $SWAP_PART
248
### -----------------------------------------------------------
246
### -----------------------------------------------------------
249
### to do !!!!!!!!!!
247
if [ $SWAP_PART ]; then
250
###
-
 
-
 
248
    echo "Make swap on $SWAP_PART ..."
251
if [ ! $NOGRUB ]; then
249
    mkswap $SWAP_PART
252
    echo
250
    echo
253
fi
251
fi
254
 
252
 
255
 
253
 
256
### format $INSTALL_PART
254
### format $INSTALL_PART
Line 268... Line 266...
268
echo "done."; echo
266
echo "done."; echo
269
 
267
 
270
 
268
 
271
### copy root dirs
269
### copy root dirs
272
### -----------------------------------------------------------
270
### -----------------------------------------------------------
273
echo "Copy Live System to $INSTALL_PART:"
271
echo "Copy Live System to $INSTALL_PART ..."
274
root_dirs=$( ls / )
272
root_dirs=$( ls / )
275
for dir in $root_dirs; do
273
for dir in $root_dirs; do
276
    # check if dir is not in $DIR_NOT_COPY
274
    # check if dir is not in $DIR_NOT_COPY
277
    do_not_copy=""
275
    do_not_copy=""
278
    for not_dir in $DIR_NOT_COPY; do
276
    for not_dir in $DIR_NOT_COPY; do
Line 310... Line 308...
310
### create dirs which were not copied
308
### create dirs which were not copied
311
### -----------------------------------------------------------
309
### -----------------------------------------------------------
312
for dir in $DIR_NOT_COPY; do
310
for dir in $DIR_NOT_COPY; do
313
    mkdir $NEW/$dir
311
    mkdir $NEW/$dir
314
done
312
done
-
 
313
# we do not need this directories
315
rmdir $NEW/livecd $NEW/mnt
314
rmdir $NEW/livecd
-
 
315
# if not yet existing, create
-
 
316
mkdir -p $NEW/srv
-
 
317
mkdir -p $NEW/selinux
316
 
318
 
317
 
319
 
318
### copy back original files
320
### copy back original files
319
### -----------------------------------------------------------
321
### -----------------------------------------------------------
320
echo -n "Restore original files ... " 
322
echo -n "Restore original files ... " 
Line 322... Line 324...
322
    [ -r $NEW/${file}.ori ] && cp -a $NEW/${file}.ori $NEW/${file} 
324
    [ -r $NEW/${file}.ori ] && cp -a $NEW/${file}.ori $NEW/${file} 
323
done
325
done
324
echo "done."; echo
326
echo "done."; echo
325
 
327
 
326
 
328
 
327
 
-
 
328
### define kernel version
329
### define kernel version
329
### -----------------------------------------------------------
330
### -----------------------------------------------------------
330
rpm --quiet -q kernel     && UP_installed=true
331
rpm --quiet -q kernel     && UP_installed=true
331
rpm --quiet -q kernel-smp && SMP_installed=true
332
rpm --quiet -q kernel-smp && SMP_installed=true
332
[ $UP_installed ]  && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel 2>/dev/null )
333
[ $UP_installed ]  && KERNEL_VERSION=$( rpm -q --qf "%{V}-%{R}" kernel 2>/dev/null )
Line 336... Line 337...
336
    exit_now 1
337
    exit_now 1
337
fi    
338
fi    
338
 
339
 
339
 
340
 
340
 
341
 
-
 
342
if [ ! $NOGRUB ]; then
341
 
343
 
-
 
344
    ### Backup Master Boot Record MBR
-
 
345
    ### -----------------------------------------------------------
342
if [ ! $NOGRUB ]; then
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
 
343
 
358
 
344
    ### install grub
359
    ### install grub
345
    ### -----------------------------------------------------------
360
    ### -----------------------------------------------------------
346
    echo "Run grub-install: "; echo
361
    echo "Run grub-install ... "
347
    mkdir -p $NEW/boot/grub
362
    mkdir -p $NEW/boot/grub
348
    if [ $FLOPPY ]; then
363
    if [ $FLOPPY ]; then
349
	grub-install --root-directory=$NEW $MBR_DEV
364
	grub-install --root-directory=$NEW $MBR_DEV
350
    else
365
    else
351
	grub-install --no-floppy --root-directory=$NEW $MBR_DEV
366
	grub-install --no-floppy --root-directory=$NEW $MBR_DEV
Line 390... Line 405...
390
    fi
405
    fi
391
 
406
 
392
 
407
 
393
    ### create grub.conf file
408
    ### create grub.conf file
394
    ### -----------------------------------------------------------
409
    ### -----------------------------------------------------------
395
    echo "Create grub.conf:"
410
    echo "Create grub.conf ..."
396
 
411
 
397
    cat > $NEW/boot/grub/grub.conf <<EOF
412
    cat > $NEW/boot/grub/grub.conf <<EOF
398
# grub.conf generated by $SCRIPTNAME
413
# grub.conf generated by $SCRIPTNAME
399
default=0
414
default=0
400
timeout=5
415
timeout=5
Line 437... Line 452...
437
    echo "done."; echo
452
    echo "done."; echo
438
 
453
 
439
fi
454
fi
440
 
455
 
441
 
456
 
442
### install kernel into /boot
457
### install kernel etc. into /boot
443
### -----------------------------------------------------------
458
### -----------------------------------------------------------
444
echo "Install kernel(s) ..."
459
echo "Install kernel(s) ..."
445
 
460
 
446
[ -e /boot/vmlinuz ]      && BOOT_DIR=/boot
461
[ -e /boot/vmlinuz ]      && BOOT_DIR=/boot
447
[ -e /boot/boot/vmlinuz ] && BOOT_DIR=/boot/boot
462
[ -e /boot/boot/vmlinuz ] && BOOT_DIR=/boot/boot
Line 451... Line 466...
451
    exit_now 1
466
    exit_now 1
452
fi
467
fi
453
 
468
 
454
cp -a $BOOT_DIR/vmlinuz            $NEW/boot/vmlinuz-${KERNEL_VERSION}
469
cp -a $BOOT_DIR/vmlinuz            $NEW/boot/vmlinuz-${KERNEL_VERSION}
455
cp -a $BOOT_DIR/vmlinuzs           $NEW/boot/vmlinuz-${KERNEL_VERSION}smp  2>/dev/null
470
cp -a $BOOT_DIR/vmlinuzs           $NEW/boot/vmlinuz-${KERNEL_VERSION}smp  2>/dev/null
-
 
471
 
456
cp -a $BOOT_DIR/System.map-*       $NEW/boot/
472
cp -a $BOOT_DIR/System.map-*       $NEW/boot/
457
cp -a $BOOT_DIR/config-*           $NEW/boot/
473
cp -a $BOOT_DIR/config-*           $NEW/boot/
-
 
474
 
-
 
475
cp -a $BOOT_DIR/symvers-*.gz       $NEW/boot/        2>/dev/null
-
 
476
 
458
cp -a $BOOT_DIR/grub/splash.xpm.gz $NEW/boot/grub/
477
cp -a $BOOT_DIR/grub/splash.xpm.gz $NEW/boot/grub/
-
 
478
 
-
 
479
cp -a $BOOT_DIR/message.ja         $NEW/boot/        2>/dev/null
-
 
480
cp -a $BOOT_DIR/message            $NEW/boot/        2>/dev/null
-
 
481
 
459
echo "done."; echo
482
echo "done."; echo
460
 
483
 
461
 
484
 
462
### create /etc/fstab
485
### create /etc/fstab
463
### -----------------------------------------------------------
486
### -----------------------------------------------------------
Line 511... Line 534...
511
done
534
done
512
 
535
 
513
 
536
 
514
### restore cronjobs
537
### restore cronjobs
515
### -----------------------------------------------------------
538
### -----------------------------------------------------------
516
mv /etc/cron_backup/sysstat /etc/cron.d/ 2>/dev/null
539
mv $NEW/etc/cron_backup/sysstat $NEW/etc/cron.d/ 2>/dev/null
517
mv /etc/cron_backup/00-makewhatis.cron.weekly /etc/cron.weekly/00-makewhatis.cron 2>/dev/null
540
mv $NEW/etc/cron_backup/00-makewhatis.cron.weekly $NEW/etc/cron.weekly/00-makewhatis.cron 2>/dev/null
518
mv /etc/cron_backup/* /etc/cron.daily/
541
mv $NEW/etc/cron_backup/* $NEW/etc/cron.daily/
519
 
542
 
520
 
543
 
521
### turn on kudzu again
544
### turn on kudzu again
522
### -----------------------------------------------------------
545
### -----------------------------------------------------------
523
chkconfig kudzu on
546
chroot $NEW chkconfig kudzu on
524
 
547
 
525
 
548
 
526
### umount $INSTALL_PART
549
### umount $INSTALL_PART
527
### -----------------------------------------------------------
550
### -----------------------------------------------------------
528
umount $INSTALL_PART
551
umount $INSTALL_PART
529
 
552
 
530
 
553
 
531
### print summary
554
### print summary
532
### -----------------------------------------------------------
555
### -----------------------------------------------------------
533
echo "-----------------------------------------------------------"
556
echo                     "--------------------------------------------------------------"
534
echo "  LiveCD installed on partition $INSTALL_PART."
557
echo                     "  LiveCD installed on partition $INSTALL_PART"
535
[ "$SWAP_PART" ] && echo "  Partition $SWAP_PART will be used as swap partition."
558
[ "$SWAP_PART" ] && echo "  Partition $SWAP_PART will be used as swap partition"
-
 
559
echo
536
[ ! $NOGRUB ]    && echo "  GRUB installed in Master Boot Record of $MBR_DEV."
560
[ ! $NOGRUB ]    && echo "  GRUB installed in Master Boot Record (MBR) of $MBR_DEV."
-
 
561
[ ! $NOGRUB ]    && echo "  MBR saved as $MBR_FILENAME on $INSTALL_PART and on /tmp"
-
 
562
[ ! $NOGRUB ]    && echo "  If you have to restore MBR, execute under Linux:"
-
 
563
[ ! $NOGRUB ]    && echo "  # dd if=$MBR_FILENAME of=$MBR_DEV bs=512 count=1"
-
 
564
echo 
537
[ $WIN_PART ]    && echo "  Entry in grub.conf for Windows partition on $WIN_PART."
565
[ $WIN_PART ]    && echo "  Entry created in grub.conf for Windows partition $WIN_PART"
538
echo "-----------------------------------------------------------"
566
echo                     "--------------------------------------------------------------"
539
echo "End of $SCRIPTNAME."
567
echo                     "End of $SCRIPTNAME"
540
echo
568
echo