1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-30 03:41:09 +00:00
ibis/tests/scripts/start_dev_db.sh

30 lines
729 B
Bash
Raw Normal View History

2023-12-01 11:11:19 +00:00
#!/bin/bash
set -e
export PGHOST=$1
export PGDATA="$1/dev_pgdata"
2024-01-03 12:29:25 +00:00
# If cluster exists, stop the backend
2023-12-01 11:11:19 +00:00
if [ -d $PGDATA ]
then
2024-01-03 12:29:25 +00:00
# Prevent `stop` from failing if backend already stopped
2023-12-19 14:32:14 +00:00
#pg_ctl restart > /dev/null
2023-12-01 11:11:19 +00:00
pg_ctl stop
fi
2023-12-01 23:59:24 +00:00
# Remove any leftover data from revious run
2023-12-19 14:32:14 +00:00
rm -rf $1
2023-12-01 23:59:24 +00:00
2023-12-01 11:11:19 +00:00
# Create cluster
initdb --username=postgres --auth=trust --no-instructions
touch "$PGHOST/.s.PGSQL.5432"
echo "$PGHOST/.s.PGSQL.5432"
2023-12-01 11:11:19 +00:00
2024-01-03 12:29:25 +00:00
# Start backend that only listens to socket in current directory
2023-12-01 11:11:19 +00:00
pg_ctl start --options="-c listen_addresses= -c unix_socket_directories=$PGHOST"
# Setup database
psql -c "CREATE USER lemmy WITH PASSWORD 'password' SUPERUSER;" -U postgres
psql -c "CREATE DATABASE lemmy WITH OWNER lemmy;" -U postgres