Initial release
[websub-hub] / test-e2e / postgres.env
diff --git a/test-e2e/postgres.env b/test-e2e/postgres.env
new file mode 100644 (file)
index 0000000..1140fe7
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/bash
+# source this
+
+# Place the data directory inside the project directory
+export PGDATA="$(pwd)/postgres_dev-13"
+
+envname="$(basename "${PGDATA}")"
+
+# Place Postgres' Unix socket inside the data directory
+export PGHOST="$PGDATA"
+
+if [[ ! -d "$PGDATA" ]]; then
+       # If the data directory doesn't exist, create an empty one, and...
+       initdb --data-checksums
+       # ...configure it to listen only on the Unix socket, and...
+       cat >> "$PGDATA/postgresql.conf" <<-EOF
+               listen_addresses = ''
+               unix_socket_directories = '$PGHOST'
+               shared_preload_libraries = 'pg_stat_statements'
+       EOF
+       # ...create a database using the name Postgres defaults to.
+       echo "CREATE DATABASE $USER;" | postgres --single -E postgres
+fi
+
+export PS1="(${envname})${PS1}"
+
+echo<<EOF
+#
+# ex: pg_ctl -l "${PGDATA}/logfile" start
+#
+EOF