From b615a8b570bb04fbf1f0d336b3d38e796d435d0e Mon Sep 17 00:00:00 2001 From: Besart Sulejmani Date: Thu, 25 Jan 2024 13:59:28 +0100 Subject: [PATCH] add create django superuser if django superuser username is set --- bin/docker_start.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bin/docker_start.sh b/bin/docker_start.sh index 2516c4dd..90f2c706 100755 --- a/bin/docker_start.sh +++ b/bin/docker_start.sh @@ -37,6 +37,18 @@ if [ -d $fixtures_dir ]; then done fi +# Create superuser +# specify password by setting DJANGO_SUPERUSER_PASSWORD in the env +# specify username by setting DJANGO_SUPERUSER_USERNAME in the env +# specify email by setting DJANGO_SUPERUSER_EMAIL in the env +if [ -n "${DJANGO_SUPERUSER_USERNAME}" ]; then + python src/manage.py createsuperuser \ + --no-input \ + --username "${DJANGO_SUPERUSER_USERNAME}" \ + --email "${DJANGO_SUPERUSER_EMAIL:-admin@admin.org}" + unset DJANGO_SUPERUSER_USERNAME DJANGO_SUPERUSER_EMAIL DJANGO_SUPERUSER_PASSWORD +fi + # Start server >&2 echo "Starting server" uwsgi \