Skip to content

Commit e1f054b

Browse files
committed
Merge branch 'fix-160'
2 parents cb8007e + 79d3491 commit e1f054b

File tree

2 files changed

+32
-25
lines changed

2 files changed

+32
-25
lines changed

docker/docker-entrypoint.sh

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,43 @@ while ! ./manage.py migrate 2>&1; do
77
sleep 3
88
done
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
3535
from django.contrib.auth.models import User
3636
from users.models import Token
3737
if 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}')
4040
END
4141

42+
echo "💡 Superuser Username: ${SUPERUSER_NAME}, E-Mail: ${SUPERUSER_EMAIL}"
43+
fi
44+
4245
if [ "$SKIP_STARTUP_SCRIPTS" == "true" ]; then
43-
echo " Skipping startup scripts"
46+
echo "↩️ Skipping startup scripts"
4447
else
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 $@

env/netbox.env

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ REDIS_DATABASE=0
2020
REDIS_CACHE_DATABASE=1
2121
REDIS_SSL=false
2222
SECRET_KEY=r8OwDznj!!dci#P9ghmRfdu1Ysxm0AiPeDCQhKE+N_rClfWNj
23-
SUPERUSER_NAME=admin
23+
SKIP_STARTUP_SCRIPTS=false
24+
SKIP_SUPERUSER=true
25+
SUPERUSER_NAME=admin2
2426
SUPERUSER_EMAIL=admin@example.com
2527
SUPERUSER_PASSWORD=admin
2628
SUPERUSER_API_TOKEN=0123456789abcdef0123456789abcdef01234567

0 commit comments

Comments
 (0)