Improve start_db.sh

This commit is contained in:
Fabio Giovanazzi 2025-08-01 22:42:23 +02:00
parent 31939859c1
commit 7bd53730fb
No known key found for this signature in database
GPG key ID: 4BDF1B40A49FDD23

View file

@ -5,43 +5,24 @@ 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
sudo docker stop postgres
sudo docker container rm -f postgres
elif [[ $# == 1 ]] && [[ $1 == "db" ]]; then
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
echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'admin@example.com', 'admin')" | python manage.py shell
popd
elif [[ $# == 1 ]] && [[ $1 == "run" ]]; then
pushd src
python manage.py processupdates
python manage.py runserver
popd
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