#!/bin/sh
#
# This file is released under the terms of the Artistic License.
# Please see the file LICENSE, included in this package, for details.
#
# Copyright The DBT-2 Authors
#

if [ -z "${DBT2DBNAME}" ]; then
	echo "DBT2DBNAME not defined."
	exit 1
fi

while getopts "l:" OPT; do
	case ${OPT} in
	l)
		PORT=${OPTARG}
		;;
	\?)
		exit 1
		;;
	esac
done

if [ ! "${PORT}" = "" ]; then
	PORTOPT="-p ${PORT}"
fi

eval "psql -d template1 ${PORTOPT} -c \"DROP DATABASE ${DBT2DBNAME};\"" \
		|| exit 1

exit 0
