Merge branch 'v1.3-dev' as v1.3.11
[websub-hub] / test-e2e / postgres.env
1 #!/bin/bash
2 # source this
3
4 # Place the data directory inside the project directory
5 export PGDATA="$(pwd)/postgres_dev-13"
6
7 envname="$(basename "${PGDATA}")"
8
9 # Place Postgres' Unix socket inside the data directory
10 export PGHOST="$PGDATA"
11
12 if [[ ! -d "$PGDATA" ]]; then
13 # If the data directory doesn't exist, create an empty one, and...
14 initdb --data-checksums
15 # ...configure it to listen only on the Unix socket, and...
16 cat >> "$PGDATA/postgresql.conf" <<-EOF
17 listen_addresses = ''
18 unix_socket_directories = '$PGHOST'
19 shared_preload_libraries = 'pg_stat_statements'
20 EOF
21 # ...create a database using the name Postgres defaults to.
22 echo "CREATE DATABASE $USER;" | postgres --single -E postgres
23 fi
24
25 export PS1="(${envname})${PS1}"
26
27 echo<<EOF
28 #
29 # ex: pg_ctl -l "${PGDATA}/logfile" start
30 #
31 EOF