Improve start_db.sh
This commit is contained in:
parent
31939859c1
commit
7bd53730fb
1 changed files with 18 additions and 37 deletions
55
start_db.sh
55
start_db.sh
|
@ -5,43 +5,24 @@ source ./.env/bin/activate
|
||||||
export C3NAV_DATABASE=postgres://mindshub:test@localhost:5432/insignorocketdb
|
export C3NAV_DATABASE=postgres://mindshub:test@localhost:5432/insignorocketdb
|
||||||
export C3NAV_DEBUG=True
|
export C3NAV_DEBUG=True
|
||||||
|
|
||||||
if [[ $# == 0 ]] || [[ $1 != "skipdb" ]]; then
|
|
||||||
|
|
||||||
sudo docker stop postgres
|
|
||||||
sudo docker container rm -f postgres
|
|
||||||
if [[ $# == 1 ]] && [[ $1 == "stop" ]]; then
|
if [[ $# == 1 ]] && [[ $1 == "stop" ]]; then
|
||||||
echo "Just stopping the postgres container"
|
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
|
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
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue