#!/bin/bash
set -evux
PG_BIN=$(pg_config --bindir)
PG_ETC=$(pg_config --sharedir | sed 's|/usr/share/postgresql|/etc/postgresql|')
export PGPORT=5432

sudo -u postgres "${PG_BIN}/pg_ctl" \
  start \
  -D ${PG_ETC}/main \
  -o "-h localhost -p $PGPORT"
sleep 10
sudo -u postgres createuser -p "$PGPORT" root
sudo -u postgres createdb -p "$PGPORT" -O root challengercheck
sudo -u postgres createdb -p "$PGPORT" -O root talercheck
