summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc G. Fournier1997-06-01 15:40:08 +0000
committerMarc G. Fournier1997-06-01 15:40:08 +0000
commit3903296b2ab78735ba19f1fb0f5fb66593b19115 (patch)
tree4dbb33ccd71359f305ad86f1f8a007af25d3924c
parent9a5529f4d188a572b5862439e9a590342c027135 (diff)
From: Igor <[email protected]>
Subject: [PATCHES] destroydb patch I am including a patch for destroydb to ask for confirmation before deleting databases (after I accidentally deleted mine)...destroydb -y would force delete without any confirmation.
-rw-r--r--src/bin/destroydb/destroydb.sh27
1 files changed, 20 insertions, 7 deletions
diff --git a/src/bin/destroydb/destroydb.sh b/src/bin/destroydb/destroydb.sh
index 9f863a964fb..5fb2ff2313c 100644
--- a/src/bin/destroydb/destroydb.sh
+++ b/src/bin/destroydb/destroydb.sh
@@ -11,7 +11,7 @@
#
#
# 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 $
#
#-------------------------------------------------------------------------
@@ -30,10 +30,11 @@ if [ -z "$USER" ]; then
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;;
@@ -41,7 +42,6 @@ do
esac
shift;
done
-
if [ -z "$AUTHSYS" ]; then
AUTHOPT=""
else
@@ -60,12 +60,25 @@ 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