tazusb rev 12

Interactive mode if no device are specified with gen-liveusb/format
author hacker@slitaz
date Thu Mar 13 00:05:10 2008 +0100 (2008-03-13)
parents bc7ca2e2616e
children a2778922137f
files tazusb
line diff
     1.1 --- a/tazusb	Wed Mar 12 23:24:19 2008 +0100
     1.2 +++ b/tazusb	Thu Mar 13 00:05:10 2008 +0100
     1.3 @@ -8,7 +8,7 @@
     1.4  # Authors : Christophe Lincoln (Pankso) <pankso@slitaz.org>
     1.5  #           Andrew Miller (Spode) <spode@spodesabode.com>
     1.6  #
     1.7 -VERSION=20080304
     1.8 +VERSION=20080312
     1.9  
    1.10  COMMAND=$1
    1.11  TARGET_ROOT=/media/flash
    1.12 @@ -55,6 +55,34 @@
    1.13  	fi
    1.14  }
    1.15  
    1.16 +# Display a list of available partition.
    1.17 +fdisk_list()
    1.18 +{
    1.19 +	echo ""
    1.20 +	fdisk -l | grep ^/dev/sd*
    1.21 +	echo ""
    1.22 +}
    1.23 +
    1.24 +# We need a USB media to install.
    1.25 +ask_for_device()
    1.26 +{
    1.27 +	echo -n "\
    1.28 +Please specify the target USB device to $COMMAND. You can type 'list' to 
    1.29 +get a list of devices, type 'exit' or give an empty value to exit.
    1.30 +
    1.31 +Device to use : "; read anser
    1.32 +	while [ "$anser" == "list" ]; do
    1.33 +		fdisk_list
    1.34 +		echo -n "Device to use : "; read anser
    1.35 +	done
    1.36 +	if [ "$anser" = "" -o "$anser" = "exit" ]; then
    1.37 +		echo -e "\nNo specified device or exit.\n"
    1.38 +		exit 0
    1.39 +	else
    1.40 +		DEVICE=$anser
    1.41 +	fi
    1.42 +}
    1.43 +
    1.44  # Verify a device exists before format or install
    1.45  check_for_device()
    1.46  {
    1.47 @@ -63,7 +91,6 @@
    1.48  		echo -e "\nUnable to find device: $DEVICE\n"
    1.49  		exit 0
    1.50  	fi
    1.51 -	DEVID=${DEVICE%?}
    1.52  }
    1.53  
    1.54  #gets the UUID and filesystem type
    1.55 @@ -123,10 +150,10 @@
    1.56  	fi
    1.57  	
    1.58  	mkdir -p /media/cdrom
    1.59 -	mount -t iso9660 $CDROM /media/cdrom
    1.60 +	mount -r -t iso9660 $CDROM /media/cdrom 2>/dev/null
    1.61  	
    1.62  	if [ ! -f /media/cdrom/boot/rootfs.gz ]; then
    1.63 -		echo -e "\nUnable to find a filesystem on the cdrom (rootfs.gz).\n"
    1.64 +		echo -e "\nUnable to mount cdrom or to find a filesystem on it (rootfs.gz).\n"
    1.65  		exit 0
    1.66  	fi
    1.67  }
    1.68 @@ -151,7 +178,7 @@
    1.69  		status
    1.70  	else
    1.71  		# Skip MBR install (tazpkg get-install syslinux-extra ? and then cat)
    1.72 -		echo "No new MBR installed to: $DEVID"
    1.73 +		echo "No new MBR installed to: $DISK"
    1.74  	fi
    1.75  }
    1.76  
    1.77 @@ -339,11 +366,11 @@
    1.78  		echo "==============================================================================="
    1.79  		DEVICE=$2
    1.80  		if [ -z $DEVICE ]; then
    1.81 -			echo -e "\nPlease specify a device to format: tazusb $COMMAND /dev/name\n"
    1.82 -			exit 0
    1.83 +			ask_for_device
    1.84 +			check_for_device
    1.85 +		else
    1.86 +			echo "Device : $DEVICE"
    1.87  		fi
    1.88 -		check_for_device
    1.89 -		echo "Device : $DEVICE"
    1.90  		mkfs_ext3
    1.91  		echo "==============================================================================="
    1.92  		echo "Device $label ($DEVICE) is ready to use as LiveUSB and/or /home partition."
    1.93 @@ -357,8 +384,7 @@
    1.94  		echo "==============================================================================="
    1.95  		DEVICE=$2
    1.96  		if [ -z $DEVICE ]; then
    1.97 -			echo -e "\No device specified. Usage: tazusb $CAMMAND /dev/name\n"
    1.98 -			exit 0
    1.99 +			ask_for_device
   1.100  		fi
   1.101  		
   1.102  		check_for_device