|
11 | 11 | #
|
12 | 12 | #
|
13 | 13 | # IDENTIFICATION
|
14 |
| -# $Header: /cvsroot/pgsql/src/bin/createdb/Attic/createdb.sh,v 1.6 1996/11/17 03:54:44 bryanh Exp $ |
| 14 | +# $Header: /cvsroot/pgsql/src/bin/createdb/Attic/createdb.sh,v 1.7 1997/11/07 06:25:25 thomas Exp $ |
15 | 15 | #
|
16 | 16 | #-------------------------------------------------------------------------
|
17 | 17 |
|
18 | 18 | CMDNAME=`basename$0`
|
19 | 19 |
|
20 | 20 | if [-z"$USER" ];then
|
21 |
| -if [-z"$LOGNAME" ];then |
22 |
| -if [-z"`whoami`" ];then |
23 |
| -echo"$CMDNAME: cannot determine user name" |
24 |
| -exit 1 |
| 21 | +if [-z"$LOGNAME" ];then |
| 22 | +if [-z"`whoami`" ];then |
| 23 | +echo"$CMDNAME: cannot determine user name" |
| 24 | +exit 1 |
| 25 | +fi |
| 26 | +else |
| 27 | +USER=$LOGNAME |
| 28 | +export USER |
25 | 29 | fi
|
26 |
| -else |
27 |
| -USER=$LOGNAME |
28 |
| -export USER |
29 |
| -fi |
30 | 30 | fi
|
31 | 31 |
|
32 | 32 | dbname=$USER
|
33 | 33 |
|
34 | 34 | whiletest -n"$1"
|
35 | 35 | do
|
36 |
| -case$1in |
37 |
| --a) AUTHSYS=$2;shift;; |
38 |
| - -h) PGHOST=$2;shift;; |
39 |
| - -p) PGPORT=$2;shift;; |
40 |
| -*) dbname=$1;; |
41 |
| -esac |
42 |
| -shift; |
| 36 | +case$1in |
| 37 | +--help) usage=1;; |
| 38 | + |
| 39 | +-a) AUTHSYS=$2;shift;; |
| 40 | +-h) PGHOST=$2;shift;; |
| 41 | +-p) PGPORT=$2;shift;; |
| 42 | +-D) dbpath=$2;shift;; |
| 43 | +-*)echo"$CMDNAME: unrecognized parameter$1"; usage=1;; |
| 44 | +*) dbname=$1;; |
| 45 | +esac |
| 46 | +shift; |
43 | 47 | done
|
44 | 48 |
|
| 49 | +if ["$usage" ];then |
| 50 | +echo"Usage:$CMDNAME -a <authtype> -h <server> -p <portnumber> -D <location> [dbname]" |
| 51 | +exit 1 |
| 52 | +fi |
| 53 | + |
45 | 54 | if [-z"$AUTHSYS" ];then
|
46 |
| -AUTHOPT="" |
| 55 | +AUTHOPT="" |
47 | 56 | else
|
48 |
| -AUTHOPT="-a$AUTHSYS" |
| 57 | +AUTHOPT="-a$AUTHSYS" |
49 | 58 | fi
|
50 | 59 |
|
51 | 60 | if [-z"$PGHOST" ];then
|
52 |
| -PGHOSTOPT="" |
| 61 | +PGHOSTOPT="" |
53 | 62 | else
|
54 |
| -PGHOSTOPT="-h$PGHOST" |
| 63 | +PGHOSTOPT="-h$PGHOST" |
55 | 64 | fi
|
56 | 65 |
|
57 | 66 | if [-z"$PGPORT" ];then
|
58 |
| - PGPORTOPT="" |
| 67 | +PGPORTOPT="" |
| 68 | +else |
| 69 | +PGPORTOPT="-p$PGPORT" |
| 70 | +fi |
| 71 | + |
| 72 | +if [-z"$dbpath" ];then |
| 73 | +location="" |
59 | 74 | else
|
60 |
| - PGPORTOPT="-p$PGPORT" |
| 75 | +#if [ ! -d "$dbpath"/base ]; then |
| 76 | +#echo "$CMDNAME: database creation failed on $dbname." |
| 77 | +#echo "directory $dbpath/base not found." |
| 78 | +#exit 1 |
| 79 | +#fi |
| 80 | +location="with location = '$dbpath'" |
61 | 81 | fi
|
62 | 82 |
|
63 |
| -psql -tq$AUTHOPT$PGHOSTOPT$PGPORTOPT -c"create database$dbname" template1 |
| 83 | +psql -tq$AUTHOPT$PGHOSTOPT$PGPORTOPT -c"create database$dbname$location" template1 |
64 | 84 |
|
65 | 85 | if [$?-ne 0 ];then
|
66 |
| -echo"$CMDNAME: database creation failed on$dbname." |
67 |
| -exit 1 |
| 86 | +echo"$CMDNAME: database creation failed on$dbname." |
| 87 | +exit 1 |
68 | 88 | fi
|
69 | 89 |
|
70 | 90 | exit 0
|