@@ -7,40 +7,43 @@ while ! ./manage.py migrate 2>&1; do
7
7
sleep 3
8
8
done
9
9
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 " ↩️ Skipp creating the superuser"
12
+ else
13
+ if [ -z ${SUPERUSER_NAME+x} ]; then
14
+ SUPERUSER_NAME=' admin'
22
15
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
29
32
fi
30
- fi
31
-
32
- echo " 💡 Username: ${SUPERUSER_NAME} , E-Mail: ${SUPERUSER_EMAIL} "
33
33
34
- ./manage.py shell --interface python << END
34
+ ./manage.py shell --interface python << END
35
35
from django.contrib.auth.models import User
36
36
from users.models import Token
37
37
if not User.objects.filter(username='${SUPERUSER_NAME} '):
38
38
u=User.objects.create_superuser('${SUPERUSER_NAME} ', '${SUPERUSER_EMAIL} ', '${SUPERUSER_PASSWORD} ')
39
39
Token.objects.create(user=u, key='${SUPERUSER_API_TOKEN} ')
40
40
END
41
41
42
+ echo " 💡 Superuser Username: ${SUPERUSER_NAME} , E-Mail: ${SUPERUSER_EMAIL} "
43
+ fi
44
+
42
45
if [ " $SKIP_STARTUP_SCRIPTS " == " true" ]; then
43
- echo " ☇ Skipping startup scripts"
46
+ echo " ↩️ Skipping startup scripts"
44
47
else
45
48
for script in /opt/netbox/startup_scripts/* .py; do
46
49
echo " ⚙️ Executing '$script '"
@@ -55,4 +58,6 @@ echo "✅ Initialisation is done."
55
58
56
59
# launch whatever is passed by docker
57
60
# (i.e. the RUN instruction in the Dockerfile)
58
- exec ${@ }
61
+ #
62
+ # shellcheck disable=SC2068
63
+ exec $@
0 commit comments