Clean postgres driver variables and add postgres-9.1 support
[hcoop/domtool2.git] / src / plugins / domtool-postgres
index d05999f..03320d0 100755 (executable)
@@ -1,17 +1,19 @@
 #!/bin/sh -e
 
 #!/bin/sh -e
 
+export PGPORT="$2"
+
 case $1 in
        adduser)
 case $1 in
        adduser)
-               USERNAME=$2
+               USERNAME=$3
 
                sudo -u postgres psql -h postgres -c "CREATE USER $USERNAME" template1
                sudo -u postgres psql -h postgres -c "ALTER TABLESPACE user_$USERNAME OWNER TO $USERNAME"
        ;;
 
        createdb)
 
                sudo -u postgres psql -h postgres -c "CREATE USER $USERNAME" template1
                sudo -u postgres psql -h postgres -c "ALTER TABLESPACE user_$USERNAME OWNER TO $USERNAME"
        ;;
 
        createdb)
-               USERNAME=$2
-               DBNAME_BASE=$3
-               ENCODING=$4
+               USERNAME=$3
+               DBNAME_BASE=$4
+               ENCODING=$5
                DBNAME="${USERNAME}_${DBNAME_BASE}"
 
                if [ -n "$ENCODING" ]; then
                DBNAME="${USERNAME}_${DBNAME_BASE}"
 
                if [ -n "$ENCODING" ]; then
@@ -22,8 +24,8 @@ case $1 in
        ;;
 
        dropdb)
        ;;
 
        dropdb)
-               USERNAME=$2
-               DBNAME_BASE=$3
+               USERNAME=$3
+               DBNAME_BASE=$4
                DBNAME="${USERNAME}_${DBNAME_BASE}"
 
                sudo -u postgres dropdb -h postgres $DBNAME
                DBNAME="${USERNAME}_${DBNAME_BASE}"
 
                sudo -u postgres dropdb -h postgres $DBNAME