Add echo to start_db.sh

This commit is contained in:
Fabio Giovanazzi 2025-08-01 22:47:40 +02:00
parent 7bd53730fb
commit 603329fbda
No known key found for this signature in database
GPG key ID: 4BDF1B40A49FDD23

View file

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
set -o xtrace # print commands being executed set -e
source ./.env/bin/activate source ./.env/bin/activate
export C3NAV_DATABASE=postgres://mindshub:test@localhost:5432/insignorocketdb export C3NAV_DATABASE=postgres://mindshub:test@localhost:5432/insignorocketdb
@ -9,7 +9,9 @@ if [[ $# == 1 ]] && [[ $1 == "stop" ]]; then
echo "Just stopping the postgres container" echo "Just stopping the postgres container"
sudo docker stop postgres sudo docker stop postgres
sudo docker container rm -f postgres sudo docker container rm -f postgres
echo "Stopped the postgres container"
elif [[ $# == 1 ]] && [[ $1 == "db" ]]; then elif [[ $# == 1 ]] && [[ $1 == "db" ]]; then
echo "Setting up database"
sudo docker run -d --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=test -e POSTGRES_USER=mindshub postgres 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 until psql "postgres://mindshub:test@localhost:5432" <<< "CREATE DATABASE insignorocketdb;"; do
sleep 0.5; sleep 0.5;
@ -20,9 +22,13 @@ elif [[ $# == 1 ]] && [[ $1 == "db" ]]; then
python manage.py migrate 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 echo "from django.contrib.auth.models import User; User.objects.create_superuser('admin', 'admin@example.com', 'admin')" | python manage.py shell
popd popd
echo "Successfully setup database"
elif [[ $# == 1 ]] && [[ $1 == "run" ]]; then elif [[ $# == 1 ]] && [[ $1 == "run" ]]; then
echo "Processing updates and running server"
pushd src pushd src
python manage.py processupdates python manage.py processupdates
python manage.py runserver python manage.py runserver
popd popd
else
echo "Usage: $0 [stop|db|run]"
fi fi