From: Igor <igor@sba.miami.edu>
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.
This commit is contained in:
parent
9a5529f4d1
commit
3903296b2a
@ -11,7 +11,7 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
# IDENTIFICATION
|
# 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
|
fi
|
||||||
|
|
||||||
dbname=$USER
|
dbname=$USER
|
||||||
|
forcedel=f
|
||||||
while [ -n "$1" ]
|
while [ -n "$1" ]
|
||||||
do
|
do
|
||||||
case $1 in
|
case $1 in
|
||||||
|
-y) forcedel=t;;
|
||||||
-a) AUTHSYS=$2; shift;;
|
-a) AUTHSYS=$2; shift;;
|
||||||
-h) PGHOST=$2; shift;;
|
-h) PGHOST=$2; shift;;
|
||||||
-p) PGPORT=$2; shift;;
|
-p) PGPORT=$2; shift;;
|
||||||
@ -41,7 +42,6 @@ do
|
|||||||
esac
|
esac
|
||||||
shift;
|
shift;
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$AUTHSYS" ]; then
|
if [ -z "$AUTHSYS" ]; then
|
||||||
AUTHOPT=""
|
AUTHOPT=""
|
||||||
else
|
else
|
||||||
@ -60,12 +60,25 @@ else
|
|||||||
PGPORTOPT="-p $PGPORT"
|
PGPORTOPT="-p $PGPORT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
psql -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "drop database $dbname" template1
|
answer=y
|
||||||
|
if [ "$forcedel" = f ]
|
||||||
if [ $? -ne 0 ]
|
|
||||||
then
|
then
|
||||||
echo "$CMDNAME: database destroy failed on $dbname."
|
answer=f
|
||||||
|
|
||||||
|
while [ "$answer" != y -a "$answer" != n ]
|
||||||
|
do
|
||||||
|
echo -n "Are you sure? (y/n) "
|
||||||
|
read answer
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$answer" = y ]
|
||||||
|
then
|
||||||
|
psql -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "drop database $dbname" template1
|
||||||
|
if [ $? -ne 0 ]
|
||||||
|
then echo "$CMDNAME: database destroy failed on $dbname."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user