#! /bin/sh
#
#   seldisk.sh - ディスクの選択 (floppy版)
#
#	0.0: Jun. 19, 2004 by Dai ISHIJIMA
#	0.1: Feb.  7, 2010 (for ubuntu-gpxe)
#	0.2: Feb. 16, 2010 (check ubuntu, puppy, slax)
#


disks=`ls -1 $DEVICES 2>/dev/null | sed 's/^.dev.//' | tr '\012' ' '`

echo ''; echo ''; echo ''
echo '*** select a disk to erase data'
echo ''
n=0
m=0
for d in $disks ; do
	dkinfo=`fdisk -l "/dev/$d" 2>/dev/null | grep "^Disk /dev/"`
	echo "    $n: $dkinfo"
	m=$n
	n=$(( $n + 1 ))
done
echo ''
echo -n "which drive to erase data? [0-$m]: "
read ans

case x"$ans" in
	x[0-9]*)
		n=0;
		for d in $disks ; do
			if [ "$n" = "$ans" ]; then
				break
			fi
			n=$(( $n + 1 ))
		done
		;;
	*)
		d=$disk
		;;
esac

disk=$d

# EOF
