by Roboprog · 11y ago · 0 comments
(puts tablespace in folder under current directory)
<code>
#!/bin/sh -x
# create and run an empty database
# note: fails miserably if there are spaces in directory names
PGDATA=`pwd`/pgdata
export PGDATA
# make it if not there
mkdir -p $PGDATA
# clean it out if anything there
/bin/rm -rf $PGDATA/*
# set up the database directory layout
initdb
# start the server process
nohup postgres 2>&1 > postgres.log &
sleep 2
# create an empty DB/schema
createdb edrs_test_db
# create a user and password ("demo") to use for connections
psql -d edrs_test_db -c "create user guest password 'guest'"
ps auxww | grep '[p]ostgres'
echo run tail -f postgres.log to monitor database
# vi: nu ai ts=4 sw=4
# * EOF *
</code>
"edrs" is the name of an app - sub in something more applicable. I'm running this on OXS, but should work on Linux as well.
I'll look into that, though, as it sounds like the right thing vs the sleep hack.
(before the file redirection instead of after)