#
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/bin/destroydb/Attic/destroydb.sh,v 1.6 1996/11/17 03:54:58 bryanh Exp $
+# $Header: /cvsroot/pgsql/src/bin/destroydb/Attic/destroydb.sh,v 1.7 1997/06/01 15:40:08 scrappy Exp $
#
#-------------------------------------------------------------------------
fi
dbname=$USER
-
+forcedel=f
while [ -n "$1" ]
do
case $1 in
+ -y) forcedel=t;;
-a) AUTHSYS=$2; shift;;
-h) PGHOST=$2; shift;;
-p) PGPORT=$2; shift;;
esac
shift;
done
-
if [ -z "$AUTHSYS" ]; then
AUTHOPT=""
else
PGPORTOPT="-p $PGPORT"
fi
-psql -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "drop database $dbname" template1
+answer=y
+if [ "$forcedel" = f ]
+ then
+ answer=f
-if [ $? -ne 0 ]
+ while [ "$answer" != y -a "$answer" != n ]
+ do
+ echo -n "Are you sure? (y/n) "
+ read answer
+ done
+fi
+
+if [ "$answer" = y ]
then
- echo "$CMDNAME: database destroy failed on $dbname."
- exit 1
+ psql -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "drop database $dbname" template1
+ if [ $? -ne 0 ]
+ then echo "$CMDNAME: database destroy failed on $dbname."
+ exit 1
+ fi
fi
exit 0