]> Untitled Git - lemmy.git/blob - scripts/start_dev_db.sh
add enable_federated_downvotes site option
[lemmy.git] / scripts / start_dev_db.sh
1 # This script is meant to be run with `source` so it can set environment variables.
2
3 export PGDATA="$PWD/dev_pgdata"
4 export PGHOST=$PWD
5 export LEMMY_DATABASE_URL="postgresql://lemmy:password@/lemmy?host=$PWD"
6
7 # If cluster exists, stop the server and delete the cluster
8 if [ -d $PGDATA ]
9 then
10   # Prevent `stop` from failing if server already stopped
11   pg_ctl restart > /dev/null
12   pg_ctl stop
13   rm -rf $PGDATA
14 fi
15
16 # Create cluster
17 initdb --username=postgres --auth=trust --no-instructions
18
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
21
22 # Setup database
23 psql -c "CREATE USER lemmy WITH PASSWORD 'password' SUPERUSER;" -U postgres
24 psql -c "CREATE DATABASE lemmy WITH OWNER lemmy;" -U postgres