This repository has been archived on 2023-07-09. You can view files and clone it, but cannot push or open issues or pull requests.
sudoscientist-go-backend/db_reset.sh
2020-01-14 22:40:32 -05:00

18 lines
662 B
Bash
Executable file

#!/bin/bash
docker stop sudosci-db
docker rm sudosci-db
export DB_ADMIN_PW=test
docker run --name sudosci-db -e POSTGRES_PASWORD=${DB_ADMIN_PW} -d postgres
cd ${GOPATH}/src/git.minhas.io/asara/sudoscientist-go-backend
for i in settings/*; do source $i; done
export DB_HOST=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" sudosci-db)
# instance takes a while to setup and configure postgis
sleep 10
psql -d postgres -U postgres -h ${DB_HOST} << EOF
CREATE DATABASE ${DB_NAME};
CREATE USER ${DB_USER} WITH ENCRYPTED PASSWORD '${DB_PW}';
GRANT ALL PRIVILEGES ON DATABASE ${DB_NAME} TO ${DB_USER};
ALTER DATABASE ${DB_NAME} OWNER TO ${DB_USER};
EOF
echo Done