Change dbtool to create user only (and assign tablespace ownership for Postgres)
[hcoop/domtool2.git] / src / plugins / domtool-postgres
CommitLineData
d541c618
AC
1#!/bin/sh -e
2
3case $1 in
4 adduser)
53cb7cc1
AC
5 USERNAME=$2
6
7 sudo -u postgres psql -c "CREATE USER $USERNAME" template1
8 sudo -u postgres psql -c "ALTER TABLESPACE user_$USERNAME OWNER TO $USERNAME"
d541c618
AC
9 ;;
10 createdb)
a215ab4e
AC
11 USERNAME=$2
12 DBNAME_BASE=$3
13 DBNAME="${USERNAME}_${DBNAME_BASE}"
14
15 sudo -u postgres createdb -O $USERNAME -D user_$USERNAME $DBNAME
d541c618
AC
16 ;;
17 *)
18 echo "Usage: domtool-postgres [adduser <user> | createdb <user> <table>]"
19 ;;
20esac