HCoop
/
hcoop
/
scripts.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Create postgresql 9.1 tablespaces for users
[hcoop/scripts.git]
/
create-user-database
diff --git
a/create-user-database
b/create-user-database
old mode 100644
(file)
new mode 100755
(executable)
index
4725bd8
..
22a4b86
--- a/
create-user-database
+++ b/
create-user-database
@@
-3,20
+3,34
@@
# DO NOT EXECUTE DIRECTLY
# This is only to be executed by create-user
# DO NOT EXECUTE DIRECTLY
# This is only to be executed by create-user
-PATHBITS=$1
+USER=$1
+# (If it's not clear, for user fred, PATHBITS = f/fr/fred)
+PATHBITS=`echo $USER | head -c 1`/`echo $USER | head -c 2`/$USER
DBPATH=/srv/databases/$PATHBITS
PGDIR=$DBPATH/postgres
DBPATH=/srv/databases/$PATHBITS
PGDIR=$DBPATH/postgres
+PGNEWDIR="$DBPATH/postgres-9.1"
MYSQLDIR=$DBPATH/mysql
# Create postgres user and tablespace placeholder within volume
MYSQLDIR=$DBPATH/mysql
# Create postgres user and tablespace placeholder within volume
+# FIXME: This assumes the status-quo of database accounts not being
+# removed by destroy-user...
if ! test -d $PGDIR; then
if ! test -d $PGDIR; then
+# postgres 8.1
mkdir -p $PGDIR
chown postgres:postgres $PGDIR
mkdir -p $PGDIR
chown postgres:postgres $PGDIR
+ sudo -u postgres psql --cluster 8.1/main -c "CREATE TABLESPACE \"user_$USER\" OWNER postgres LOCATION '$PGDIR'" template1
fi
fi
-sudo -u postgres psql -c "CREATE TABLESPACE user_$USER OWNER postgres LOCATION '$PGDIR'" template1
+if ! test -d $PGNEWDIR; then
+# postgres 9.1
+ mkdir -p $PGNEWDIR
+ chown postgres:postgres $PGNEWDIR
+ sudo -u postgres psql --cluster 9.1/main -c "CREATE TABLESPACE \"user_$USER\" OWNER postgres LOCATION '$PGNEWDIR'" template1
fi
# Create mysql user and databases placeholder within volume
fi
# Create mysql user and databases placeholder within volume
-mkdir -p $MYSQLDIR
-chown mysql:mysql $MYSQLDIR
\ No newline at end of file
+# FIXME: Same as postgres...
+if ! test -d $MYSQLDIR; then
+ mkdir -p $MYSQLDIR
+ chown mysql:mysql $MYSQLDIR
+fi
\ No newline at end of file