|
From: Heiko Z. <he...@zu...> - 2004-05-18 00:46:49
|
All Done. But there's still a problem: when the script copies the stuff onto the device, cp prints a warning about omitting the directories grub and lilo. Can you take a look at this? Heiko Tim Tait wrote: > Tim Tait wrote: > >> >> In the process of fixing the broken gub/lilo support, I've made some >> significant chnages to "install-on-usb", hopefully you will find them >> as useful as I do. The diff as well as the complete file is attached >> for easier review. Item (5) means install-on-usb should be included >> inside the ISO as well, hence the mods to copy-base. >> >> Comments? >> >> Tim >> >> ---------------------------- >> Changes: >> 1. Fixed Grub/Lilo stuff to copy the bootcd.iso rather than the whole >> contents. >> >> 2. Auto-replaced /dev/sda style device names with link contents (who >> likes having to type that??) to allow to work with devfs. >> >> 3. Added prompts for formerly implict selections embedded in script >> (such as choice of grub/lilo/syslinux) >> >> 4. Added prompt/support for initrd with ext2 (changes required ramdisk >> block size) >> >> 5. Added ability to make the bootcd.iso from the actual DL CD itself - >> solves chicken-and-egg problem, no need to get ISO and Dist archive. >> In theory allows boot of target machine from CD and self-install to >> USB/disk. I did not test this yet, but did install CD based image OK. >> dd copy is done with info based on isosize so does not have problems >> with CD-Rs and creates binary duplicate of original iso. >> >> 6. Option to copy your own config file to disk, with option to use >> different partition (recommended). >> >> 7. General code cleanup. > > > Oops, one mistake with the sequence of events for the fdisk need to get > the device before I can call fdisk. Last minute changes always get you:) > Fixed now. > > Tim > > > ------------------------------------------------------------------------ > > #!/bin/bash > # > # $Source: /cvsroot/devil-linux/build/scripts/scripts/install-on-usb,v $ > # $Revision: 1.12 $ > # $Date: 2003/11/16 16:29:38 $ > # > # http://www.devil-linux.org > # > # This script will install Devil-Linux on a USB storage DEVICE > # > # > > TMPDIR="./tmp-install2usb" > > #### Pick your favorite disk part tool: > FDISK="fdisk" > #FDISK="cfdisk" > > copy_iso_file () > { > # $1 = source device or file > # $2 = target file path > > isosize_bin="$TMPDIR/iso-mnt/usr/bin/isosize" > if [ -b "$1" ]; then > #which isosize || { echo "Utility isosize not found - can not copy from a CD."; return 1; } > echo "copying image of CD in $1 to device mounted on $2" > iso_info=`$isosize_bin -x $1` > nsectors=`echo $iso_info | cut -d' ' -f3 | cut -d',' -f1` > bs=`echo $iso_info | cut -d' ' -f6` > nice dd bs=$bs count=$nsectors if=$1 of=$2 || return 1 > return 0 > elif [ -f "$1" ]; then > echo "copying source file $1 to device mounted on $2" > nice cp -p $1 $2 || return 1 > return 0 > else > echo "$1 is not a valid source for the ISO" > return 1 > fi > } > > ask_yes_no () > { > ANS="" > read -p " (y/n) " -t 60 -n 1 -rs ANS > echo $ANS > [ ${ANS:-n} = "y" -o ${ANS:-n} = "Y" ] && return 0 > return 1 > } > > ## most USB parts taken from the usb-mount script from Michael Hamilton ( mi...@ac... ) > #function scsiDevFromScsiUsb { > # echo $1 | awk -F"[-/]" '{ n=$(NF-1); print "/dev/sd" substr("abcdefghijklmnopqrstuvwxyz", n+1, 1) "1" }' > #} > # > #function allAttachedScsiUsb { > # find /proc/scsi/ -path '/proc/scsi/usb-storage*' -type f | xargs grep -l 'Attached: Yes' > #} > # > #function allDetachedScsiUsb { > # find /proc/scsi/ -path '/proc/scsi/usb-storage*' -type f | xargs grep -l 'Attached: No' > #} > > install_lilo () > { > echo "Configuring LILO boot sector and menu" > cat > $TMPDIR/disk-mnt/boot/lilo.conf <<-EOF > read-only > compact > lba32 > timeout = 60 > # Override dangerous defaults that rewrite the partition table: > change-rules > reset > default = Devil-Linux > message = /boot/message > disk = /dev/sda > bios = 0x80 > > image = /boot/vmlinuz > label = Devil-Linux > append = "init=/linuxrc $RAMDISK" > root = /dev/ram0 > initrd = /boot/initrd.gz > > EOF > cp /boot/boot.b tmp/disk-mnt/boot/ || return 1 > cp /boot/mbr.b tmp/disk-mnt/boot/ || return 1 > lilo -r $TMPDIR/disk-mnt -C /boot/lilo.conf -M $1 || return 1 > lilo -r $TMPDIR/disk-mnt -C /boot/lilo.conf -b $1 || return 1 > } > > install_grub () > { > echo "Configuring Grub boot sector and menu..." > grub_shell=$TMPDIR/iso-mnt/sbin/grub > device_map=grub-tmp-map > force_lba="" > > if [ ! -f "$grub_shell" ]; then > echo "Grub not found in ISO image - was it included in the DL build?" > umount $TMPDIR/iso-mnt #|| exit 1 > umount $TMPDIR/disk-mnt #|| exit 1 > exit 1 > fi > > rm -f $device_map > > cat > $TMPDIR/disk-mnt/boot/grub/grub.conf <<-EOF > timeout=10 > splashimage=(hd0,$2)/boot/grub/devil-linux.xpm.gz > title Devil-Linux - Standard VGA > root (hd0,$2) > kernel /boot/vmlinuz ro root=/dev/ram0 init=/linuxrc $RAMDISK > initrd /boot/initrd.gz > title Devil-Linux - VESA Frame Buffer 640x480 > root (hd0,$2) > kernel /boot/vmlinuz ro root=/dev/ram0 init=/linuxrc $RAMDISK vga=769 > initrd /boot/initrd.gz > title Devil-Linux - VESA Frame Buffer 800x600 > root (hd0,$2) > kernel /boot/vmlinuz ro root=/dev/ram0 init=/linuxrc $RAMDISK vga=771 > initrd /boot/initrd.gz > title Devil-Linux - VESA Frame Buffer 1024x768 > root (hd0,$2) > kernel /boot/vmlinuz ro root=/dev/ram0 init=/linuxrc $RAMDISK vga=773 > initrd /boot/initrd.gz > title Devil-Linux - Other > root (hd0,$2) > kernel /boot/vmlinuz ro root=/dev/ram0 init=/linuxrc $RAMDISK vga=ask > initrd /boot/initrd.gz > EOF > if [ -f "$TMPDIR/disk-mnt/boot/memtest" ]; then > cat >> $TMPDIR/disk-mnt/boot/grub/grub.conf <<-EOF > title Memtest86 > root (hd0,$2) > kernel /boot/memtest > EOF > fi > pushd $TMPDIR/disk-mnt/boot/grub > /dev/null > rm -f menu.lst > ln -s grub.conf menu.lst > popd > /dev/null > > $grub_shell --batch --device-map=$device_map <<-EOF > /dev/null > quit > EOF > > install_drive=$(grep "$1\$" $device_map|cut -f1) > root_drive="${install_drive%%)},0)" > > $grub_shell --batch --device-map=$device_map <<-EOF > /dev/null > root $root_drive > setup $force_lba $install_drive > quit > EOF > rm -f $device_map > } > > install_dl () > { > > if [ -d "$TMPDIR" ]; then > # unclean exit before > umount $TMPDIR/iso-mnt &> /dev/null > umount $TMPDIR/disk-mnt &> /dev/null > rm -rf $TMPDIR &> /dev/null > fi > > mkdir -p $TMPDIR/iso-mnt || return 1 > mkdir -p $TMPDIR/disk-mnt || return 1 > > # echo "Available USB storage devices: " > # for device in $(allAttachedScsiUsb) > # do > # echo -n "$(scsiDevFromScsiUsb $device) " > # done > > echo > read -p "Enter DL ISO source (disk file or CD device) -> " DLISO > > if [ -L "$DLISO" ]; then > DLISO=$(readlink -fns $DLISO) > echo " Expanding link to: $DLISO" > fi > if [ ! -e "$DLISO" ]; then > echo " Cannot find file or device: $DLISO" > return 1 > fi > > if [ -b "$DLISO" ]; then > mount -t iso9660 -o ro $DLISO $TMPDIR/iso-mnt || return 1 > else > mount -o loop,ro -t iso9660 $DLISO $TMPDIR/iso-mnt || return 1 > fi > if [ -f "$TMPDIR/iso-mnt/DEVIL-LINUX" ]; then > dl_version=`cat $TMPDIR/iso-mnt/DEVIL-LINUX` > echo " Devil Linux $dl_version found in ISO" > else > echo > echo "$DLISO does not seem to contain Devil-Linux!" > return 1 > fi > > echo > read -p "Enter DEVICE name of disk device (i.e. /dev/sda) -> " DEVICE > > $FDISK -l $DEVICE > > echo > echo "If you wish to store the ISO and configuration on the same media, two partitions are recommended." > echo -n "Do you want to partition the media first? " > ask_yes_no && $FDISK $DEVICE > > echo > read -p "Enter PARTITION name of disk device to put ISO file (i.e. /dev/sda1) -> " PARTITION > > if [ -L "$PARTITION" ]; then > PARTITION=$(readlink -fns $PARTITION) > echo " Expanding link to full partition name for devfs : $PARTITION" > fi > if [ ! -b "$PARTITION" ]; then > echo " Cannot find device: $PARTITION" > return 1 > fi > > if [ -L "$DEVICE" ]; then > DEVICE=$(readlink -fns $DEVICE) > echo " Expanding link to full device name for devfs : $DEVICE" > fi > if [ ! -b "$DEVICE" ]; then > echo " Cannot find device: $DEVICE" > return 1 > fi > > echo > ETC_FILE="" > read -p "Enter configuration file to preload to disk (if any) -> " ETC_FILE > if [ -n "$ETC_FILE" ]; then > if [ ! -f "$ETC_FILE" ]; then > echo " No such file: \"$ETC_FILE\"" > return 1 > else > read -p "Enter seperate partition for configuration (recommended) or enter if same -> " ETC_PART > if [ -z "$ETC_PART" ]; then > ETC_PART=$PARTITION > elif [ ! -b "$ETC_PART" ]; then > echo " Can not find partition \"$ETC_PART\"" > return 1 > else > echo;echo -n "All data on device $ETC_PART will be lost, continue ? " > ask_yes_no || return 1 > > echo;echo -n "Last chance, do you really want to continue ? " > ask_yes_no || return 1 > > mkfs.ext2 $ETC_PART > /dev/null || return 1 > fi > fi > fi > > echo > echo "This will install DL on \"$DEVICE\" using the \"$BOOTLOADER\" bootloader. " > > if [ "$BOOTLOADER" = "syslinux" ]; then > echo "Please make sure the partition type is 'FAT16' (06) " > echo > else > echo "Please make sure the partition type is 'Linux' (83) " > echo > fi > > echo;echo -n "All data on device $PARTITION will be lost, continue ? " > ask_yes_no || return 1 > > echo;echo -n "Last chance, do you really want to continue ? " > ask_yes_no || return 1 > > if [ "$BOOTLOADER" = "syslinux" ]; then > > mkfs.msdos $PARTITION > /dev/null || return 1 > > echo "Installing syslinux MBR" > SIZE=$(du -b $TMPDIR/iso-mnt/boot/syslinux/mbr.bin | cut -f 1 ) > dd if=$TMPDIR/iso-mnt/boot/syslinux/mbr.bin of=$DEVICE count=$SIZE || return 1 > echo installing SysLinux boot sector > $TMPDIR/iso-mnt/boot/syslinux/syslinux-nomtools $PARTITION || return 1 > > mount -t vfat $PARTITION $TMPDIR/disk-mnt || return 1 > > echo "copying files" > cp -p $TMPDIR/iso-mnt/boot/* $TMPDIR/disk-mnt/ > /dev/null > cp -p $TMPDIR/iso-mnt/{DEVIL-LINUX,LICENSE} $TMPDIR/disk-mnt/ > /dev/null > cat $TMPDIR/iso-mnt/isolinux.cfg | sed -e s%"/boot/"%""% > $TMPDIR/disk-mnt/syslinux.cfg || return 1 > cat $TMPDIR/iso-mnt/boot/message | sed -e s%"/boot/"%""% > $TMPDIR/disk-mnt/message || return 1 > copy_iso_file $DLISO $TMPDIR/disk-mnt/bootcd.iso || return 1 > > elif [ "$BOOTLOADER" = "grub" ] || [ "$BOOTLOADER" = "lilo" ]; then > > mkfs.ext2 $PARTITION > /dev/null || return 1 > tune2fs -c 0 $PARTITION > > mount -t auto $PARTITION $TMPDIR/disk-mnt || return 1 > > echo "copying files" > cp -a $TMPDIR/iso-mnt/boot/ $TMPDIR/disk-mnt/ > /dev/null > cp -p $TMPDIR/iso-mnt/{DEVIL-LINUX,LICENSE} $TMPDIR/disk-mnt/ > /dev/null > copy_iso_file $DLISO $TMPDIR/disk-mnt/bootcd.iso || return 1 > GRUBPART=$(expr $(basename ${PARTITION} | sed -e 's/^part//' -e 's/^[hs]d[a-z]//') - 1) > > [ "$BOOTLOADER" = "grub" ] && install_grub $DEVICE $GRUBPART > [ "$BOOTLOADER" = "lilo" ] && install_lilo $DEVICE > > else > echo "Unknown Bootloader: $BOOTLOADER" > return 1 > fi > > if [ -n "$ETC_FILE" ]; then > mkdir -p $TMPDIR/etc-mnt > mount -t auto $ETC_PART $TMPDIR/etc-mnt > echo > echo "Copying $ETC_FILE to $TMPDIR/etc-mnt/etc.tar.bz2" > cp -p $ETC_FILE $TMPDIR/etc-mnt/etc.tar.bz2 > /dev/null || return 1 > sync > umount $TMPDIR/etc-mnt > /dev/null > fi > > return 0; > } > > ########################################################################## > > echo > echo "This will install the Devil Linux ISO image to a disk device (USB/SCSI/IDE)" > echo "and make it bootable, assuming that your PC can boot this device." > > ### Get some user info for the install > echo > echo "Select which bootloader you want to use:" > echo " 1) SysLinux" > echo " 2) Grub" > echo " 3) Lilo" > ANS="" > read -p "Choice: " -t 60 -n 1 -rs ANS > ANS=${ANS:-1} > echo $ANS > > ### set the default > BOOTLOADER="syslinux" > #BOOTLOADER="grub" > #BOOTLOADER="lilo" > > [ ${ANS:-n} = "1" ] && BOOTLOADER="syslinux" > [ ${ANS:-n} = "2" ] && BOOTLOADER="grub" > [ ${ANS:-n} = "3" ] && BOOTLOADER="lilo" > > #### Choose the format used during build for initrd.gz: > echo > echo "Select correct initrd.gz format used (DL default is CramFS):" > echo " 1) CramFS" > echo " 2) Ext2" > ANS="" > read -p "Choice: " -t 60 -n 1 -rs ANS > ANS=${ANS:-1} > echo $ANS > > # For initrd.gz as CRAMFS > RAMDISK="ramdisk_blocksize=4096" > # For initrd.gz as EXT2 > #RAMDISK="ramdisk_blocksize=1024" > > [ ${ANS:-n} = "1" ] && RAMDISK="ramdisk_blocksize=4096"; > [ ${ANS:-n} = "2" ] && RAMDISK="ramdisk_blocksize=1024"; > > # Do install > install_dl || echo "Install failed!" > > echo "syncing and unmounting (this could take a while)" > sync > umount $TMPDIR/iso-mnt &> /dev/null > umount $TMPDIR/disk-mnt &> /dev/null > umount $TMPDIR/etc-mnt &> /dev/null > > rm -rf $TMPDIR &> /dev/null > > exit > > > ------------------------------------------------------------------------ > > --- ./scripts/scripts/install-on-usb.old 2004-05-15 17:36:14.000000000 +0200 > +++ ./scripts/scripts/install-on-usb 2004-05-15 22:39:51.000000000 +0200 > @@ -10,18 +10,41 @@ > # > # > > -BOOTLOADER="syslinux" > -#BOOTLOADER="grub" > -#BOOTLOADER="lilo" > +TMPDIR="./tmp-install2usb" > > +#### Pick your favorite disk part tool: > FDISK="fdisk" > #FDISK="cfdisk" > > +copy_iso_file () > +{ > + # $1 = source device or file > + # $2 = target file path > + > + isosize_bin="$TMPDIR/iso-mnt/usr/bin/isosize" > + if [ -b "$1" ]; then > + #which isosize || { echo "Utility isosize not found - can not copy from a CD."; return 1; } > + echo "copying image of CD in $1 to device mounted on $2" > + iso_info=`$isosize_bin -x $1` > + nsectors=`echo $iso_info | cut -d' ' -f3 | cut -d',' -f1` > + bs=`echo $iso_info | cut -d' ' -f6` > + nice dd bs=$bs count=$nsectors if=$1 of=$2 || return 1 > + return 0 > + elif [ -f "$1" ]; then > + echo "copying source file $1 to device mounted on $2" > + nice cp -p $1 $2 || return 1 > + return 0 > + else > + echo "$1 is not a valid source for the ISO" > + return 1 > + fi > +} > + > ask_yes_no () > { > ANS="" > read -p " (y/n) " -t 60 -n 1 -rs ANS > - echo > + echo $ANS > [ ${ANS:-n} = "y" -o ${ANS:-n} = "Y" ] && return 0 > return 1 > } > @@ -41,7 +64,8 @@ > > install_lilo () > { > - cat > ./tmp/mnt2/boot/lilo.conf <<-EOF > + echo "Configuring LILO boot sector and menu" > + cat > $TMPDIR/disk-mnt/boot/lilo.conf <<-EOF > read-only > compact > lba32 > @@ -56,68 +80,77 @@ > > image = /boot/vmlinuz > label = Devil-Linux > - append = "init=/linuxrc ramdisk_blocksize=4096" > + append = "init=/linuxrc $RAMDISK" > root = /dev/ram0 > initrd = /boot/initrd.gz > > EOF > - cp /boot/boot.b tmp/mnt2/boot/ || return 1 > - cp /boot/mbr.b tmp/mnt2/boot/ || return 1 > - lilo -r ./tmp/mnt2 -C /boot/lilo.conf -M $1 || return 1 > - lilo -r ./tmp/mnt2 -C /boot/lilo.conf -b $1 || return 1 > + cp /boot/boot.b tmp/disk-mnt/boot/ || return 1 > + cp /boot/mbr.b tmp/disk-mnt/boot/ || return 1 > + lilo -r $TMPDIR/disk-mnt -C /boot/lilo.conf -M $1 || return 1 > + lilo -r $TMPDIR/disk-mnt -C /boot/lilo.conf -b $1 || return 1 > } > > install_grub () > { > - grub_shell=./tmp/mnt2/sbin/grub > + echo "Configuring Grub boot sector and menu..." > + grub_shell=$TMPDIR/iso-mnt/sbin/grub > device_map=grub-tmp-map > force_lba="" > + > + if [ ! -f "$grub_shell" ]; then > + echo "Grub not found in ISO image - was it included in the DL build?" > + umount $TMPDIR/iso-mnt #|| exit 1 > + umount $TMPDIR/disk-mnt #|| exit 1 > + exit 1 > + fi > + > rm -f $device_map > > - cat > ./tmp/mnt2/boot/grub/grub.conf <<-EOF > + cat > $TMPDIR/disk-mnt/boot/grub/grub.conf <<-EOF > timeout=10 > splashimage=(hd0,$2)/boot/grub/devil-linux.xpm.gz > title Devil-Linux - Standard VGA > root (hd0,$2) > - kernel /boot/vmlinuz ro root=/dev/ram0 init=/linuxrc ramdisk_blocksize=4096 > + kernel /boot/vmlinuz ro root=/dev/ram0 init=/linuxrc $RAMDISK > initrd /boot/initrd.gz > title Devil-Linux - VESA Frame Buffer 640x480 > root (hd0,$2) > - kernel /boot/vmlinuz ro root=/dev/ram0 init=/linuxrc ramdisk_blocksize=4096 vga=769 > + kernel /boot/vmlinuz ro root=/dev/ram0 init=/linuxrc $RAMDISK vga=769 > initrd /boot/initrd.gz > title Devil-Linux - VESA Frame Buffer 800x600 > root (hd0,$2) > - kernel /boot/vmlinuz ro root=/dev/ram0 init=/linuxrc ramdisk_blocksize=4096 vga=771 > + kernel /boot/vmlinuz ro root=/dev/ram0 init=/linuxrc $RAMDISK vga=771 > initrd /boot/initrd.gz > title Devil-Linux - VESA Frame Buffer 1024x768 > root (hd0,$2) > - kernel /boot/vmlinuz ro root=/dev/ram0 init=/linuxrc ramdisk_blocksize=4096 vga=773 > + kernel /boot/vmlinuz ro root=/dev/ram0 init=/linuxrc $RAMDISK vga=773 > initrd /boot/initrd.gz > title Devil-Linux - Other > root (hd0,$2) > - kernel /boot/vmlinuz ro root=/dev/ram0 init=/linuxrc ramdisk_blocksize=4096 vga=ask > + kernel /boot/vmlinuz ro root=/dev/ram0 init=/linuxrc $RAMDISK vga=ask > initrd /boot/initrd.gz > EOF > - if [ -f ./tmp/mnt2/boot/memtest ]; then > - cat >> ./tmp/mnt2/boot/grub/grub.conf <<-EOF > + if [ -f "$TMPDIR/disk-mnt/boot/memtest" ]; then > + cat >> $TMPDIR/disk-mnt/boot/grub/grub.conf <<-EOF > title Memtest86 > root (hd0,$2) > kernel /boot/memtest > EOF > fi > - pushd ./tmp/mnt2/boot/grub > /dev/null > + pushd $TMPDIR/disk-mnt/boot/grub > /dev/null > rm -f menu.lst > ln -s grub.conf menu.lst > popd > /dev/null > > - $grub_shell --batch --device-map=$device_map <<-EOF > + $grub_shell --batch --device-map=$device_map <<-EOF > /dev/null > quit > EOF > > install_drive=$(grep "$1\$" $device_map|cut -f1) > root_drive="${install_drive%%)},0)" > > - $grub_shell --batch --device-map=$device_map <<-EOF > + $grub_shell --batch --device-map=$device_map <<-EOF > /dev/null > root $root_drive > setup $force_lba $install_drive > quit > @@ -125,97 +158,231 @@ > rm -f $device_map > } > > -function install > +install_dl () > { > - test -d ./tmp && rm -rf ./tmp > > - mkdir -p ./tmp/mnt{1,2} || return 1 > + if [ -d "$TMPDIR" ]; then > + # unclean exit before > + umount $TMPDIR/iso-mnt &> /dev/null > + umount $TMPDIR/disk-mnt &> /dev/null > + rm -rf $TMPDIR &> /dev/null > + fi > + > + mkdir -p $TMPDIR/iso-mnt || return 1 > + mkdir -p $TMPDIR/disk-mnt || return 1 > > # echo "Available USB storage devices: " > # for device in $(allAttachedScsiUsb) > # do > # echo -n "$(scsiDevFromScsiUsb $device) " > # done > - echo > - read -p "Enter PARTITION name on USB device (i.e. /dev/sda1) -> " PARTITION > - read -p "Enter DEVICE name of USB device (i.e. /dev/sda) -> " DEVICE > > + echo > + read -p "Enter DL ISO source (disk file or CD device) -> " DLISO > > - for device in "$PARTITION" "$DEVICE" > - do > - if [ -L $device ]; then > - echo "If you are using devfs, you must supply the full device, not the link." > - exit > - fi > - if [ ! -b $device ]; then > - echo "Cannot find: $device" > - exit > - fi > - done > + if [ -L "$DLISO" ]; then > + DLISO=$(readlink -fns $DLISO) > + echo " Expanding link to: $DLISO" > + fi > + if [ ! -e "$DLISO" ]; then > + echo " Cannot find file or device: $DLISO" > + return 1 > + fi > > - GRUBPART=$(expr $(basename ${PARTITION} | sed -e 's/^part//' -e 's/^[hs]d[a-z]//') - 1) > + if [ -b "$DLISO" ]; then > + mount -t iso9660 -o ro $DLISO $TMPDIR/iso-mnt || return 1 > + else > + mount -o loop,ro -t iso9660 $DLISO $TMPDIR/iso-mnt || return 1 > + fi > + if [ -f "$TMPDIR/iso-mnt/DEVIL-LINUX" ]; then > + dl_version=`cat $TMPDIR/iso-mnt/DEVIL-LINUX` > + echo " Devil Linux $dl_version found in ISO" > + else > + echo > + echo "$DLISO does not seem to contain Devil-Linux!" > + return 1 > + fi > > echo > - #echo "Please make sure the partition type is 'Linux' (83) " > - echo "Please make sure the partition type is 'FAT16' (06) " > - echo > + read -p "Enter DEVICE name of disk device (i.e. /dev/sda) -> " DEVICE > > $FDISK -l $DEVICE > > - echo;echo -n "Do you want to partition the media ? " > + echo > + echo "If you wish to store the ISO and configuration on the same media, two partitions are recommended." > + echo -n "Do you want to partition the media first? " > ask_yes_no && $FDISK $DEVICE > + > + echo > + read -p "Enter PARTITION name of disk device to put ISO file (i.e. /dev/sda1) -> " PARTITION > + > + if [ -L "$PARTITION" ]; then > + PARTITION=$(readlink -fns $PARTITION) > + echo " Expanding link to full partition name for devfs : $PARTITION" > + fi > + if [ ! -b "$PARTITION" ]; then > + echo " Cannot find device: $PARTITION" > + return 1 > + fi > + > + if [ -L "$DEVICE" ]; then > + DEVICE=$(readlink -fns $DEVICE) > + echo " Expanding link to full device name for devfs : $DEVICE" > + fi > + if [ ! -b "$DEVICE" ]; then > + echo " Cannot find device: $DEVICE" > + return 1 > + fi > + > + echo > + ETC_FILE="" > + read -p "Enter configuration file to preload to disk (if any) -> " ETC_FILE > + if [ -n "$ETC_FILE" ]; then > + if [ ! -f "$ETC_FILE" ]; then > + echo " No such file: \"$ETC_FILE\"" > + return 1 > + else > + read -p "Enter seperate partition for configuration (recommended) or enter if same -> " ETC_PART > + if [ -z "$ETC_PART" ]; then > + ETC_PART=$PARTITION > + elif [ ! -b "$ETC_PART" ]; then > + echo " Can not find partition \"$ETC_PART\"" > + return 1 > + else > + echo;echo -n "All data on device $ETC_PART will be lost, continue ? " > + ask_yes_no || return 1 > + > + echo;echo -n "Last chance, do you really want to continue ? " > + ask_yes_no || return 1 > + > + mkfs.ext2 $ETC_PART > /dev/null || return 1 > + fi > + fi > + fi > > - echo;echo " Partition: $PARTITION" > - echo " Device: $DEVICE" > + echo > + echo "This will install DL on \"$DEVICE\" using the \"$BOOTLOADER\" bootloader. " > > - echo;echo -n "All data on device will be lost, continue ? " > - ask_yes_no || return 0 > + if [ "$BOOTLOADER" = "syslinux" ]; then > + echo "Please make sure the partition type is 'FAT16' (06) " > + echo > + else > + echo "Please make sure the partition type is 'Linux' (83) " > + echo > + fi > + > + echo;echo -n "All data on device $PARTITION will be lost, continue ? " > + ask_yes_no || return 1 > > echo;echo -n "Last chance, do you really want to continue ? " > - ask_yes_no || return 0 > + ask_yes_no || return 1 > > if [ "$BOOTLOADER" = "syslinux" ]; then > - mkfs.msdos $PARTITION || return 1 > > - mount -o loop -t iso9660 bootcd.iso ./tmp/mnt1 || return 1 > + mkfs.msdos $PARTITION > /dev/null || return 1 > > - echo installing MBR > - SIZE=$(du -b ./tmp/mnt1/boot/syslinux/mbr.bin | cut -f 1 ) > - dd if=./tmp/mnt1/boot/syslinux/mbr.bin of=$DEVICE count=$SIZE || return 1 > + echo "Installing syslinux MBR" > + SIZE=$(du -b $TMPDIR/iso-mnt/boot/syslinux/mbr.bin | cut -f 1 ) > + dd if=$TMPDIR/iso-mnt/boot/syslinux/mbr.bin of=$DEVICE count=$SIZE || return 1 > echo installing SysLinux boot sector > - ./tmp/mnt1/boot/syslinux/syslinux-nomtools $PARTITION || return 1 > + $TMPDIR/iso-mnt/boot/syslinux/syslinux-nomtools $PARTITION || return 1 > > - mount -t vfat $PARTITION ./tmp/mnt2 || return 1 > + mount -t vfat $PARTITION $TMPDIR/disk-mnt || return 1 > > - echo copying files > - cp ./tmp/mnt1/boot/* ./tmp/mnt2/ &> /dev/null > - cp ./tmp/mnt1/{DEVIL-LINUX,LICENSE} ./tmp/mnt2/ &> /dev/null > - cat ./tmp/mnt1/isolinux.cfg | sed -e s%"/boot/"%""% > ./tmp/mnt2/syslinux.cfg || return 1 > - cat ./tmp/mnt1/boot/message | sed -e s%"/boot/"%""% > ./tmp/mnt2/message || return 1 > - cp bootcd.iso ./tmp/mnt2/ || return 1 > - fi > + echo "copying files" > + cp -p $TMPDIR/iso-mnt/boot/* $TMPDIR/disk-mnt/ > /dev/null > + cp -p $TMPDIR/iso-mnt/{DEVIL-LINUX,LICENSE} $TMPDIR/disk-mnt/ > /dev/null > + cat $TMPDIR/iso-mnt/isolinux.cfg | sed -e s%"/boot/"%""% > $TMPDIR/disk-mnt/syslinux.cfg || return 1 > + cat $TMPDIR/iso-mnt/boot/message | sed -e s%"/boot/"%""% > $TMPDIR/disk-mnt/message || return 1 > + copy_iso_file $DLISO $TMPDIR/disk-mnt/bootcd.iso || return 1 > + > + elif [ "$BOOTLOADER" = "grub" ] || [ "$BOOTLOADER" = "lilo" ]; then > > - if [ "$BOOTLOADER" = "grub" ] || [ "$BOOTLOADER" = "lilo" ]; then > - mkfs.ext2 $PARTITION || return 1 > + mkfs.ext2 $PARTITION > /dev/null || return 1 > tune2fs -c 0 $PARTITION > > - mount -o loop -t iso9660 bootcd.iso ./tmp/mnt1 || return 1 > - mount -t auto $PARTITION ./tmp/mnt2 || return 1 > + mount -t auto $PARTITION $TMPDIR/disk-mnt || return 1 > > - echo copying files... > - nice -n19 cp -dpR ./tmp/mnt1/* ./tmp/mnt2/ || return 1 > - nice -n19 cp -dpR etc.tar.bz2 ./tmp/mnt2/ || return 1 > + echo "copying files" > + cp -a $TMPDIR/iso-mnt/boot/ $TMPDIR/disk-mnt/ > /dev/null > + cp -p $TMPDIR/iso-mnt/{DEVIL-LINUX,LICENSE} $TMPDIR/disk-mnt/ > /dev/null > + copy_iso_file $DLISO $TMPDIR/disk-mnt/bootcd.iso || return 1 > + GRUBPART=$(expr $(basename ${PARTITION} | sed -e 's/^part//' -e 's/^[hs]d[a-z]//') - 1) > > [ "$BOOTLOADER" = "grub" ] && install_grub $DEVICE $GRUBPART > - [ "$BOOTLOADER" = "lilo" ] && install_lilo $DEVICE > + [ "$BOOTLOADER" = "lilo" ] && install_lilo $DEVICE > + > + else > + echo "Unknown Bootloader: $BOOTLOADER" > + return 1 > + fi > + > + if [ -n "$ETC_FILE" ]; then > + mkdir -p $TMPDIR/etc-mnt > + mount -t auto $ETC_PART $TMPDIR/etc-mnt > + echo > + echo "Copying $ETC_FILE to $TMPDIR/etc-mnt/etc.tar.bz2" > + cp -p $ETC_FILE $TMPDIR/etc-mnt/etc.tar.bz2 > /dev/null || return 1 > + sync > + umount $TMPDIR/etc-mnt > /dev/null > fi > + > + return 0; > } > > -install > +########################################################################## > + > +echo > +echo "This will install the Devil Linux ISO image to a disk device (USB/SCSI/IDE)" > +echo "and make it bootable, assuming that your PC can boot this device." > + > +### Get some user info for the install > +echo > +echo "Select which bootloader you want to use:" > +echo " 1) SysLinux" > +echo " 2) Grub" > +echo " 3) Lilo" > +ANS="" > +read -p "Choice: " -t 60 -n 1 -rs ANS > +ANS=${ANS:-1} > +echo $ANS > + > +### set the default > +BOOTLOADER="syslinux" > +#BOOTLOADER="grub" > +#BOOTLOADER="lilo" > + > +[ ${ANS:-n} = "1" ] && BOOTLOADER="syslinux" > +[ ${ANS:-n} = "2" ] && BOOTLOADER="grub" > +[ ${ANS:-n} = "3" ] && BOOTLOADER="lilo" > + > +#### Choose the format used during build for initrd.gz: > +echo > +echo "Select correct initrd.gz format used (DL default is CramFS):" > +echo " 1) CramFS" > +echo " 2) Ext2" > +ANS="" > +read -p "Choice: " -t 60 -n 1 -rs ANS > +ANS=${ANS:-1} > +echo $ANS > + > +# For initrd.gz as CRAMFS > +RAMDISK="ramdisk_blocksize=4096" > +# For initrd.gz as EXT2 > +#RAMDISK="ramdisk_blocksize=1024" > + > +[ ${ANS:-n} = "1" ] && RAMDISK="ramdisk_blocksize=4096"; > +[ ${ANS:-n} = "2" ] && RAMDISK="ramdisk_blocksize=1024"; > + > +# Do install > +install_dl || echo "Install failed!" > > echo "syncing and unmounting (this could take a while)" > sync > -umount ./tmp/mnt1 || exit 1 > -umount ./tmp/mnt2 || exit 1 > +umount $TMPDIR/iso-mnt &> /dev/null > +umount $TMPDIR/disk-mnt &> /dev/null > +umount $TMPDIR/etc-mnt &> /dev/null > + > +rm -rf $TMPDIR &> /dev/null > > -rm -rf ./tmp || exit 1 > +exit > > > ------------------------------------------------------------------------ > > --- ./scripts/copy_base.old 2004-05-15 17:56:11.000000000 +0200 > +++ ./scripts/copy_base 2004-05-14 17:17:50.000000000 +0200 > @@ -47,6 +47,7 @@ > cp -p $MYDIR/scripts/save-config $CDDIR/bin || exit 1 > cp -p $MYDIR/scripts/setup $CDDIR/bin || exit 1 > cp -p $MYDIR/scripts/upgrade-config $CDDIR/sbin || exit 1 > + cp -p $MYDIR/scripts/install-on-usb $CDDIR/sbin || exit 1 > cp -p $MYDIR/scripts/pre_init $CDDIR/sbin || exit 1 > cp -p $MYDIR/scripts/software-help $CDDIR/usr/share/devillinux || exit 1 > cp -p $MYDIR/scripts/keyboardmodels $CDDIR/usr/share/devillinux || exit 1 > |