diff --git a/docker/docker-entrypoint.sh b/docker/docker-entrypoint.sh index 53e52ef..8f1bd3f 100755 --- a/docker/docker-entrypoint.sh +++ b/docker/docker-entrypoint.sh @@ -13,7 +13,12 @@ if [[ -z ${SUPERUSER_NAME} || -z ${SUPERUSER_EMAIL} || -z ${SUPERUSER_PASSWORD} SUPERUSER_PASSWORD='admin' echo "Using defaults: Username: ${SUPERUSER_NAME}, E-Mail: ${SUPERUSER_EMAIL}, Password: ${SUPERUSER_PASSWORD}" fi -echo "from django.contrib.auth.models import User; User.objects.create_superuser('${SUPERUSER_NAME}', '${SUPERUSER_EMAIL}', '${SUPERUSER_PASSWORD}')" | python /opt/netbox/netbox/manage.py shell + +python netbox/manage.py shell --plain << END +from django.contrib.auth.models import User +if not User.objects.filter(username='${SUPERUSER_NAME}'): + User.objects.create_superuser('${SUPERUSER_NAME}', '${SUPERUSER_EMAIL}', '${SUPERUSER_PASSWORD}') +END # copy static files /opt/netbox/netbox/manage.py collectstatic --no-input