team-3/start_db.sh

47 lines
1.6 KiB
Bash
Executable file

#!/bin/bash
set -o xtrace # print commands being executed
source ./.env/bin/activate
export C3NAV_DATABASE=postgres://mindshub:test@localhost:5432/insignorocketdb
export C3NAV_DEBUG=True
if [[ $# == 0 ]] || [[ $1 != "skipdb" ]]; then
sudo docker stop postgres
sudo docker container rm -f postgres
if [[ $# == 1 ]] && [[ $1 == "stop" ]]; then
echo "Just stopping the postgres container"
exit 0
fi
sudo docker run -d --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=test -e POSTGRES_USER=mindshub postgres
until psql "postgres://mindshub:test@localhost:5432" <<< "CREATE DATABASE insignorocketdb;"; do
sleep 0.5;
done;
psql "postgres://mindshub:test@localhost:5432/insignorocketdb" < auth_user.sql
psql "postgres://mindshub:test@localhost:5432/insignorocketdb" < dump.sql
pushd src
python manage.py migrate
python manage.py processupdates
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'admin@example.com', 'admin')" | python manage.py shell
popd
#& $($(echo "$(cargo tarpaulin --print-rust-flags --target-dir=target/tarpaulin)" | grep -v INFO)) cargo build
#$(cargo tarpaulin --print-rust-flags | grep -v INFO)
#cargo tarpaulin --command build --skip-clean --target-dir=target/tarpaulin
#DATABASE_URL=
if [[ $# != 1 ]]; then
# terminate gracefully when the user uses Ctrl+C (unless an argument was passed)
#trap 'sudo docker stop postgres; sudo docker container rm -f postgres; exit' INT
echo
elif [[ $1 == "db" ]]; then
echo "Skipping tests and leaving database open"
exit 0
fi
fi
pushd src
python manage.py runserver
popd