Skip to content

Instantly share code, notes, and snippets.

@nzoschke
Created March 1, 2012 20:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nzoschke/1952801 to your computer and use it in GitHub Desktop.
Save nzoschke/1952801 to your computer and use it in GitHub Desktop.
#!/bin/sh
NAME=$1
DATADIR=${2:-.pg}
[ $NAME == "" ] && { echo usage: pg_dev NAME [DATADIR]; exit 1; }
echo Initializing database in $DATADIR
initdb $DATADIR
echo Starting Postgres
postgres -D $DATADIR &
PID=$(jobs -p)
trap "kill -TERM $PID && wait $PID" EXIT
echo Creating $NAME
for i in 1 2 3 4 5; do
createdb $NAME && break
sleep 0.5
done
wait $PID
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment