@@ -7,40 +7,43 @@ while ! ./manage.py migrate 2>&1; do
77 sleep 3
88done
99
10- # create superuser silently
11- if [ -z ${SUPERUSER_NAME+x} ]; then
12- SUPERUSER_NAME=' admin'
13- fi
14- if [ -z ${SUPERUSER_EMAIL+x} ]; then
15- SUPERUSER_EMAIL=' admin@example.com'
16- fi
17- if [ -z ${SUPERUSER_PASSWORD+x} ]; then
18- if [ -f " /run/secrets/superuser_password" ]; then
19- SUPERUSER_PASSWORD=" $( < /run/secrets/superuser_password) "
20- else
21- SUPERUSER_PASSWORD=' admin'
10+ if [ " $SKIP_SUPERUSER " == " true" ]; then
11+ echo " ↩️ Skip creating the superuser"
12+ else
13+ if [ -z ${SUPERUSER_NAME+x} ]; then
14+ SUPERUSER_NAME=' admin'
2215 fi
23- fi
24- if [ -z ${SUPERUSER_API_TOKEN+x} ]; then
25- if [ -f " /run/secrets/superuser_api_token" ]; then
26- SUPERUSER_API_TOKEN=" $( < /run/secrets/superuser_api_token) "
27- else
28- SUPERUSER_API_TOKEN=' 0123456789abcdef0123456789abcdef01234567'
16+ if [ -z ${SUPERUSER_EMAIL+x} ]; then
17+ SUPERUSER_EMAIL=' admin@example.com'
18+ fi
19+ if [ -z ${SUPERUSER_PASSWORD+x} ]; then
20+ if [ -f " /run/secrets/superuser_password" ]; then
21+ SUPERUSER_PASSWORD=" $( < /run/secrets/superuser_password) "
22+ else
23+ SUPERUSER_PASSWORD=' admin'
24+ fi
25+ fi
26+ if [ -z ${SUPERUSER_API_TOKEN+x} ]; then
27+ if [ -f " /run/secrets/superuser_api_token" ]; then
28+ SUPERUSER_API_TOKEN=" $( < /run/secrets/superuser_api_token) "
29+ else
30+ SUPERUSER_API_TOKEN=' 0123456789abcdef0123456789abcdef01234567'
31+ fi
2932 fi
30- fi
31-
32- echo " 💡 Username: ${SUPERUSER_NAME} , E-Mail: ${SUPERUSER_EMAIL} "
3333
34- ./manage.py shell --interface python << END
34+ ./manage.py shell --interface python << END
3535from django.contrib.auth.models import User
3636from users.models import Token
3737if not User.objects.filter(username='${SUPERUSER_NAME} '):
3838 u=User.objects.create_superuser('${SUPERUSER_NAME} ', '${SUPERUSER_EMAIL} ', '${SUPERUSER_PASSWORD} ')
3939 Token.objects.create(user=u, key='${SUPERUSER_API_TOKEN} ')
4040END
4141
42+ echo " 💡 Superuser Username: ${SUPERUSER_NAME} , E-Mail: ${SUPERUSER_EMAIL} "
43+ fi
44+
4245if [ " $SKIP_STARTUP_SCRIPTS " == " true" ]; then
43- echo " ☇ Skipping startup scripts"
46+ echo " ↩️ Skipping startup scripts"
4447else
4548 for script in /opt/netbox/startup_scripts/* .py; do
4649 echo " ⚙️ Executing '$script '"
@@ -55,4 +58,6 @@ echo "✅ Initialisation is done."
5558
5659# launch whatever is passed by docker
5760# (i.e. the RUN instruction in the Dockerfile)
58- exec ${@ }
61+ #
62+ # shellcheck disable=SC2068
63+ exec $@
0 commit comments