#!/bin/ksh

export PATH=/usr/X/bin:/usr/bin/:/usr/sbin/

function intro
{
	zenity --warning --title="Disk Partitioner" --text="WARNING: Partitioning a disk can be destructive to data! Know what you are doing before you change any partitions to another type."
	choose_disk
}

function choose_disk
{
	DISK=`pfexec format < /dev/null 2>&1 | /usr/xpg4/bin/grep \
	-E "[ ,	]*[0-9]*\.[ ,	]*c[0-9]"| sed 's/^[ ,	]*[0-9]*\.[	, ]//' \
	| zenity --list --title="Disk Partitioner" --column="Disks" \
	--width="500" --height="200"`

	if [ -z $DISK ]; then
		ask_quit
	else
		DISK=`echo "$DISK"|sed 's/\(c[0-9].*d[0-9]\).*/\1p0/'`
		xterm +sb +hold -T "Disk Partitioner" -n "Disk Partitioner" -e pfexec fdisk $DISK
	fi
	ask_quit
}

function ask_quit
{
	zenity --question --title="Disk Partitioner" \
		--text="Woule you like to quit?" || choose_disk
	exit 0
}

intro
