1 # This script is meant to be run with `source` so it can set environment variables.
3 export PGDATA="$PWD/dev_pgdata"
5 export LEMMY_DATABASE_URL="postgresql://lemmy:password@/lemmy?host=$PWD"
7 # If cluster exists, stop the server and delete the cluster
10 # Prevent `stop` from failing if server already stopped
11 pg_ctl restart > /dev/null
17 initdb --username=postgres --auth=trust --no-instructions
19 # Start server that only listens to socket in current directory
20 pg_ctl start --options="-c listen_addresses= -c unix_socket_directories=$PWD" > /dev/null
23 psql -c "CREATE USER lemmy WITH PASSWORD 'password' SUPERUSER;" -U postgres
24 psql -c "CREATE DATABASE lemmy WITH OWNER lemmy;" -U postgres