Commit c97f6fd1 authored by Thomas G. Lockhart's avatar Thomas G. Lockhart

Add "-D location" to specify alternate database location.

parent 75d5ce28
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/bin/createdb/Attic/createdb.sh,v 1.6 1996/11/17 03:54:44 bryanh Exp $ # $Header: /cvsroot/pgsql/src/bin/createdb/Attic/createdb.sh,v 1.7 1997/11/07 06:25:25 thomas Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -34,14 +34,23 @@ dbname=$USER ...@@ -34,14 +34,23 @@ dbname=$USER
while test -n "$1" while test -n "$1"
do do
case $1 in case $1 in
--help) usage=1;;
-a) AUTHSYS=$2; shift;; -a) AUTHSYS=$2; shift;;
-h) PGHOST=$2; shift;; -h) PGHOST=$2; shift;;
-p) PGPORT=$2; shift;; -p) PGPORT=$2; shift;;
-D) dbpath=$2; shift;;
-*) echo "$CMDNAME: unrecognized parameter $1"; usage=1;;
*) dbname=$1;; *) dbname=$1;;
esac esac
shift; shift;
done done
if [ "$usage" ]; then
echo "Usage: $CMDNAME -a <authtype> -h <server> -p <portnumber> -D <location> [dbname]"
exit 1
fi
if [ -z "$AUTHSYS" ]; then if [ -z "$AUTHSYS" ]; then
AUTHOPT="" AUTHOPT=""
else else
...@@ -60,7 +69,18 @@ else ...@@ -60,7 +69,18 @@ else
PGPORTOPT="-p $PGPORT" PGPORTOPT="-p $PGPORT"
fi fi
psql -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "create database $dbname" template1 if [ -z "$dbpath" ]; then
location=""
else
# if [ ! -d "$dbpath"/base ]; then
# echo "$CMDNAME: database creation failed on $dbname."
# echo "directory $dbpath/base not found."
# exit 1
# fi
location="with location = '$dbpath'"
fi
psql -tq $AUTHOPT $PGHOSTOPT $PGPORTOPT -c "create database $dbname $location" template1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "$CMDNAME: database creation failed on $dbname." echo "$CMDNAME: database creation failed on $dbname."
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment