diff --git a/start_db.sh b/start_db.sh index 8e775337..7a588491 100755 --- a/start_db.sh +++ b/start_db.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -o xtrace # print commands being executed +set -e source ./.env/bin/activate export C3NAV_DATABASE=postgres://mindshub:test@localhost:5432/insignorocketdb @@ -9,7 +9,9 @@ if [[ $# == 1 ]] && [[ $1 == "stop" ]]; then echo "Just stopping the postgres container" sudo docker stop postgres sudo docker container rm -f postgres + echo "Stopped the postgres container" 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 until psql "postgres://mindshub:test@localhost:5432" <<< "CREATE DATABASE insignorocketdb;"; do sleep 0.5; @@ -20,9 +22,13 @@ elif [[ $# == 1 ]] && [[ $1 == "db" ]]; then 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 + echo "Successfully setup database" elif [[ $# == 1 ]] && [[ $1 == "run" ]]; then + echo "Processing updates and running server" pushd src python manage.py processupdates python manage.py runserver popd +else + echo "Usage: $0 [stop|db|run]" fi