Checks if the superuser exists before creating it

This commit is contained in:
Christian Mäder 2017-04-21 13:43:44 +02:00
parent 582b2abea8
commit fee1eed522
No known key found for this signature in database
GPG Key ID: 92FFD0A711F196BB

View File

@ -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