tazusb rev 24

Add gen-iso2usb command. Generate LiveUSB from ISO file
author Eric Joseph-Alexandre <erjo@slitaz.org>
date Wed May 14 23:30:18 2008 +0200 (2008-05-14)
parents d4ec240412fc
children 6c960dd30d6b
files tazusb
line diff
     1.1 --- a/tazusb	Tue May 13 10:14:48 2008 +0200
     1.2 +++ b/tazusb	Wed May 14 23:30:18 2008 +0200
     1.3 @@ -31,7 +31,8 @@
     1.4    format	Format and label device with ext3 filesystem 
     1.5                  (for LiveUSB or /home).
     1.6    gen-liveusb 	Generate a bootable LiveUSB using files from the LiveCD.
     1.7 -  gen-swap      Creat or recreat and active additionnal swap memory.\n"
     1.8 +  gen-swap      Creat or recreat and active additionnal swap memory.
     1.9 +  gen-iso2usb   Generate a bootable LiveUSB using files from ISO file\n"
    1.10  }
    1.11  
    1.12  # Status function.
    1.13 @@ -159,6 +160,25 @@
    1.14  	fi
    1.15  }
    1.16  
    1.17 +# Mount SliTaz ISO to get needed files.
    1.18 +mount_iso()
    1.19 +{
    1.20 +	if mount | grep /media/cdrom ; then
    1.21 +		umount /media/cdrom
    1.22 +	fi
    1.23 +	
    1.24 +	test -d /media/cdrom || mkdir -p /media/cdrom
    1.25 +	
    1.26 +	echo  "Mounting `basename $ISO`..."
    1.27 +	mount $ISO /media/cdrom 2>/dev/null
    1.28 +	
    1.29 +	if [ ! -f /media/cdrom/boot/rootfs.gz ]; then
    1.30 +		echo -e "\nUnable to mount iso or to find a filesystem on it (rootfs.gz).\n"
    1.31 +		exit 0
    1.32 +	fi
    1.33 +}
    1.34 +
    1.35 +
    1.36  # All needed files are in the boot direcory of the cdrom.
    1.37  copy_cdrom_files()
    1.38  {
    1.39 @@ -425,6 +445,34 @@
    1.40  		check_root
    1.41  		gen_swap_file
    1.42  		;;
    1.43 +	gen-iso2usb)
    1.44 +		check_root
    1.45 +
    1.46 +		# Check if file exists
    1.47 +		ISO=$2
    1.48 +		if [ -z $ISO ] || [ ! -f $ISO ]; then
    1.49 +			echo -e "\nPlease specify a valid filename on the command line.\n"
    1.50 +			exit 1
    1.51 +		fi
    1.52 +		echo ""
    1.53 +		echo -e "\033[1mCopy ISO file to SliTaz LiveUSB media\033[0m"
    1.54 +		echo "==============================================================================="
    1.55 +		echo ""
    1.56 +		DEVICE=$3
    1.57 +		if [ -z $DEVICE ]; then
    1.58 +			ask_for_device
    1.59 +		fi
    1.60 +		check_for_device
    1.61 +		mount_iso
    1.62 +		get_part_info
    1.63 +		unmount_target_usb
    1.64 +		install_mbr
    1.65 +		set_bootable
    1.66 +		mount_target_usb
    1.67 +		copy_cdrom_files
    1.68 +		install_boot
    1.69 +		exit_or_reboot
    1.70 +		;;		
    1.71  	usage|*)
    1.72  		# Display usage by default.
    1.73  		usage