Commit | Line | Data |
---|---|---|
82cda9f8 CE |
1 | #!/bin/bash -ex |
2 | ||
3 | # DO NOT EXECUTE DIRECTLY | |
4 | # This is only to be executed by create-user | |
5 | ||
58df4059 CE |
6 | USER=$1 |
7 | # (If it's not clear, for user fred, PATHBITS = f/fr/fred) | |
8 | PATHBITS=`echo $USER | head -c 1`/`echo $USER | head -c 2`/$USER | |
82cda9f8 CE |
9 | DBPATH=/srv/databases/$PATHBITS |
10 | PGDIR=$DBPATH/postgres | |
2735eb24 | 11 | PGNEWDIR="$DBPATH/postgres-9.1" |
82cda9f8 CE |
12 | MYSQLDIR=$DBPATH/mysql |
13 | ||
14 | # Create postgres user and tablespace placeholder within volume | |
658c76a0 | 15 | # FIXME: This assumes the status-quo of database accounts not being |
16 | # removed by destroy-user... | |
82cda9f8 | 17 | if ! test -d $PGDIR; then |
2735eb24 | 18 | # postgres 8.1 |
82cda9f8 CE |
19 | mkdir -p $PGDIR |
20 | chown postgres:postgres $PGDIR | |
2735eb24 | 21 | sudo -u postgres psql --cluster 8.1/main -c "CREATE TABLESPACE \"user_$USER\" OWNER postgres LOCATION '$PGDIR'" template1 |
22 | fi | |
23 | ||
24 | if ! test -d $PGNEWDIR; then | |
25 | # postgres 9.1 | |
26 | mkdir -p $PGNEWDIR | |
27 | chown postgres:postgres $PGNEWDIR | |
28 | sudo -u postgres psql --cluster 9.1/main -c "CREATE TABLESPACE \"user_$USER\" OWNER postgres LOCATION '$PGNEWDIR'" template1 | |
82cda9f8 CE |
29 | fi |
30 | ||
82cda9f8 | 31 | # Create mysql user and databases placeholder within volume |
658c76a0 | 32 | # FIXME: Same as postgres... |
33 | if ! test -d $MYSQLDIR; then | |
34 | mkdir -p $MYSQLDIR | |
35 | chown mysql:mysql $MYSQLDIR | |
36 | fi |