docker-entrypoint.sh 897 B

12345678910111213141516171819202122
  1. #!/bin/bash
  2. set -e
  3. # run db migrations (retry on error)
  4. while ! /opt/netbox/netbox/manage.py migrate 2>&1; do
  5. sleep 5
  6. done
  7. # create superuser silently
  8. if [[ -z ${SUPERUSER_NAME} || -z ${SUPERUSER_EMAIL} || -z ${SUPERUSER_PASSWORD} ]]; then
  9. SUPERUSER_NAME='admin'
  10. SUPERUSER_EMAIL='admin@example.com'
  11. SUPERUSER_PASSWORD='admin'
  12. echo "Using defaults: Username: ${SUPERUSER_NAME}, E-Mail: ${SUPERUSER_EMAIL}, Password: ${SUPERUSER_PASSWORD}"
  13. fi
  14. 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
  15. # copy static files
  16. /opt/netbox/netbox/manage.py collectstatic --no-input
  17. # start unicorn
  18. gunicorn --log-level debug --debug --error-logfile /dev/stderr --log-file /dev/stdout -c /opt/netbox/gunicorn_config.py netbox.wsgi