Skip to content

Commit

Permalink
ENT-23: add hooks for running pre- and post-init scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
RangerRick committed May 15, 2024
1 parent 1265d22 commit 4db48b0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
#!/bin/bash
# Runs on every start of the NetBox Docker container

# Stop when an error occures
# Stop when an error occurs
set -e

# Allows NetBox to be run as non-root users
umask 002

if [ -d /opt/init/pre ]; then
for FILE in /opt/init/pre/*.sh; do
echo "⚙️ Running pre-init script '${FILE}'..."
"${FILE}" "$@"
done
fi

# Load correct Python3 env
# shellcheck disable=SC1091
source /opt/netbox/venv/bin/activate
Expand Down Expand Up @@ -91,8 +98,15 @@ except Token.DoesNotExist:
pass
END

if [ -d /opt/init/post ]; then
for FILE in /opt/init/post/*.sh; do
echo "⚙️ Running post-init script '${FILE}'..."
"${FILE}" "$@"
done
fi

echo "✅ Initialisation is done."

# Launch whatever is passed by docker
# (i.e. the RUN instruction in the Dockerfile)
# (i.e. the CMD instruction in the Dockerfile)
exec "$@"

0 comments on commit 4db48b0

Please sign in to comment.