New mod_waklog version
[hcoop/domtool2.git] / src / plugins / domtool-postgres
1 #!/bin/sh -e
2
3 case $1 in
4 adduser)
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"
9 ;;
10 createdb)
11 USERNAME=$2
12 DBNAME_BASE=$3
13 DBNAME="${USERNAME}_${DBNAME_BASE}"
14
15 sudo -u postgres createdb -O $USERNAME -D user_$USERNAME $DBNAME
16 ;;
17 *)
18 echo "Usage: domtool-postgres [adduser <user> | createdb <user> <table>]"
19 ;;
20 esac