#! /bin/sh
#
#   mainmenu.sh -- ハードディスク消去ツールメイン
#

dmesg=/var/run/dmesg.boot
resultfil=/tmp/result
disks=`sed -n -E '/^(da|ad)[0-9]:.*</p' $dmesg | sed 's/^\(...\).*/\1/'`
set $disks
disk=$1

while true ; do
	dname=`sed -n -E "/^${disk}:.*<.*>/p" $dmesg | sed 's/.*\(<.*>\).*/\1/'`
	bytes=`diskinfo -B /dev/r$disk`
	cap=`diskinfo -p /dev/r$disk`

	echo '*** Hard Disk wiping tool "wipe-out" ***'
	echo ''
	echo "current disk: /dev/${disk} ${dname}"
	echo "    capacity: $bytes bytes ($cap)"
	echo ''
	echo '    0: write "0" onto the disk'
	echo '    1: write "1" onto the disk'
	echo '    2: write random data onto the disk'
	echo '    3: select disk'
	echo '    4: run shell (sh)'
	echo ''
	echo -n 'enter number [0-4]: '
	read ans

	case x"${ans}" in
		x0)
			sh erase.sh -z $disk
			;;
		x1)
			sh erase.sh -f $disk
			;;
		x2)
			sh erase.sh -r $disk
			;;
		x3)
			. seldisk.sh
			;;
		x4)
			/bin/sh -i
			;;
	esac
	echo ''; echo ''; echo ''
done

exit 0

# EOF
