#!/bin/sh

set -e

PACKAGE=onshore-timesheet

case $1 in
    purge)
	if su postgres -c "psql -l" 2>/dev/null | grep -q timesheet; then
	    default=n
	    read -p "Would you like to destroy the 'timesheet' database? " input
	    case "$input" in
		Y|y) input=y ;;
		N|n) input=n ;;
		'') input=$default ;;
		*)
		    echo "'$input' not understood.  Using default of '$default'."
		    input=$default
		;;
	    esac
	    if [ "$input" = "y" ]; then
		su postgres -c 'destroydb timesheet' || true
	    fi
	fi
	;;
esac

#DEBHELPER#

exit 0

	
