Update with-db.sh
This commit is contained in:
parent
a24f9bcde1
commit
d6a9e7156f
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,3 +4,5 @@ dist-newstyle
|
||||
*.swp
|
||||
result
|
||||
bench.html
|
||||
download
|
||||
pgdata
|
||||
|
||||
17
with-db.sh
17
with-db.sh
@ -1,14 +1,21 @@
|
||||
BASE_DIR=$(mktemp -d)
|
||||
if [ -z "$BASE_DIR" ]; then
|
||||
BASE_DIR=$(mktemp -d)
|
||||
fi
|
||||
export PGDATA="$BASE_DIR/pgdata"
|
||||
|
||||
# On error or exit: Stop the DB server
|
||||
stop_db_server() {
|
||||
pg_ctl stop --wait
|
||||
pg_ctl stop -o "-p 5433" --wait
|
||||
}
|
||||
trap stop_db_server EXIT
|
||||
|
||||
initdb --username=yore-test --auth=trust
|
||||
pg_ctl start --wait
|
||||
createdb yore-test --username=yore-test
|
||||
if [ ! -s "$PGDATA/PG_VERSION" ]; then
|
||||
initdb --username=yore-test --auth=trust || true
|
||||
DO_CREATE_DB=1
|
||||
fi
|
||||
pg_ctl start -o "-p 5433" --wait
|
||||
if [ -n "$DO_CREATE_DB" ]; then
|
||||
createdb -p 5433 yore-test --username=yore-test || true
|
||||
fi
|
||||
|
||||
"$@"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user