2025-08-01 20:43:04 +02:00
|
|
|
#!/bin/bash
|
2025-08-01 22:47:40 +02:00
|
|
|
set -e
|
2025-08-01 20:43:04 +02:00
|
|
|
|
|
|
|
source ./.env/bin/activate
|
|
|
|
export C3NAV_DATABASE=postgres://mindshub:test@localhost:5432/insignorocketdb
|
|
|
|
export C3NAV_DEBUG=True
|
|
|
|
|
|
|
|
if [[ $# == 1 ]] && [[ $1 == "stop" ]]; then
|
|
|
|
echo "Just stopping the postgres container"
|
2025-08-01 22:42:23 +02:00
|
|
|
sudo docker stop postgres
|
|
|
|
sudo docker container rm -f postgres
|
2025-08-01 22:47:40 +02:00
|
|
|
echo "Stopped the postgres container"
|
2025-08-01 22:42:23 +02:00
|
|
|
elif [[ $# == 1 ]] && [[ $1 == "db" ]]; then
|
2025-08-01 22:47:40 +02:00
|
|
|
echo "Setting up database"
|
2025-08-01 22:42:23 +02:00
|
|
|
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
|
2025-08-01 22:47:40 +02:00
|
|
|
echo "Successfully setup database"
|
2025-08-01 22:42:23 +02:00
|
|
|
elif [[ $# == 1 ]] && [[ $1 == "run" ]]; then
|
2025-08-01 22:47:40 +02:00
|
|
|
echo "Processing updates and running server"
|
2025-08-01 22:42:23 +02:00
|
|
|
pushd src
|
|
|
|
python manage.py processupdates
|
|
|
|
python manage.py runserver
|
|
|
|
popd
|
2025-08-01 22:47:40 +02:00
|
|
|
else
|
|
|
|
echo "Usage: $0 [stop|db|run]"
|
2025-08-01 20:43:04 +02:00
|
|
|
fi
|