Created
March 1, 2012 20:11
-
-
Save nzoschke/1952801 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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