#!/bin/bash -x
if ! mount | grep /var/lib/pgsql; then /sbin/service postgresql stop
mount -t tmpfs tmpfs /var/lib/pgsql
chown postgres:postgres /var/lib/pgsql chmod 700 /var/lib/pgsql
/sbin/service postgresql initdb
cat > /var/lib/pgsql/data/pg_hba.conf <<EOL local all all trust host all all 127.0.0.1/32 trust host all all ::1/128 ident EOL
/sbin/service postgresql start su - postgres -c "echo -e "CREATE USER dcloud WITH PASSWORD 'v23zj59an' CREATEDB;\n\q" | psql"
rake dc:setup
else echo Postgresql is already on tmpfs fi