From 7bd53730fb8c5a0401e95c83fa2c8b2502cc0607 Mon Sep 17 00:00:00 2001 From: Stypox Date: Fri, 1 Aug 2025 22:42:23 +0200 Subject: [PATCH] Improve start_db.sh --- start_db.sh | 55 ++++++++++++++++++----------------------------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/start_db.sh b/start_db.sh index ade101e5..8e775337 100755 --- a/start_db.sh +++ b/start_db.sh @@ -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