Skip to content

Commit

Permalink
Add support for custom init scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
bianjp committed Oct 30, 2024
1 parent 7aba297 commit 6fea8be
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions 3.8.4/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ RUN set -eux; \
netcat \
wget; \
rm -rf /var/lib/apt/lists/*; \
mkdir /docker-entrypoint.d && \
# Verify that gosu binary works
gosu nobody true

Expand Down
30 changes: 30 additions & 0 deletions 3.8.4/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,36 @@ if [[ "$1" = 'zkServer.sh' && "$(id -u)" = '0' ]]; then
exec gosu zookeeper "$0" "$@"
fi

if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
echo "Loading shell scripts in /docker-entrypoint.d/"
for f in $(find "/docker-entrypoint.d/" -follow -type f -print | sort -V); do
case "$f" in
*.envsh)
if [ -x "$f" ]; then
echo "Sourcing $f";
. "$f"
else
# warn on shell scripts without exec bit
echo "Ignoring $f, not executable";
fi
;;
*.sh)
if [ -x "$f" ]; then
echo "Launching $f";
"$f"
else
# warn on shell scripts without exec bit
echo "Ignoring $f, not executable";
fi
;;
*) echo "Ignoring $f";;
esac
done
echo "Loaded shell scripts in /docker-entrypoint.d/"
else
echo "No files found in /docker-entrypoint.d/"
fi

# Generate the config only if it doesn't exist
if [[ ! -f "$ZOO_CONF_DIR/zoo.cfg" ]]; then
CONFIG="$ZOO_CONF_DIR/zoo.cfg"
Expand Down
1 change: 1 addition & 0 deletions 3.9.3/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ RUN set -eux; \
netcat \
wget; \
rm -rf /var/lib/apt/lists/*; \
mkdir /docker-entrypoint.d && \
# Verify that gosu binary works
gosu nobody true

Expand Down
30 changes: 30 additions & 0 deletions 3.9.3/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,36 @@ if [[ "$1" = 'zkServer.sh' && "$(id -u)" = '0' ]]; then
exec gosu zookeeper "$0" "$@"
fi

if /usr/bin/find "/docker-entrypoint.d/" -mindepth 1 -maxdepth 1 -type f -print -quit 2>/dev/null | read v; then
echo "Loading shell scripts in /docker-entrypoint.d/"
for f in $(find "/docker-entrypoint.d/" -follow -type f -print | sort -V); do
case "$f" in
*.envsh)
if [ -x "$f" ]; then
echo "Sourcing $f";
. "$f"
else
# warn on shell scripts without exec bit
echo "Ignoring $f, not executable";
fi
;;
*.sh)
if [ -x "$f" ]; then
echo "Launching $f";
"$f"
else
# warn on shell scripts without exec bit
echo "Ignoring $f, not executable";
fi
;;
*) echo "Ignoring $f";;
esac
done
echo "Loaded shell scripts in /docker-entrypoint.d/"
else
echo "No files found in /docker-entrypoint.d/"
fi

# Generate the config only if it doesn't exist
if [[ ! -f "$ZOO_CONF_DIR/zoo.cfg" ]]; then
CONFIG="$ZOO_CONF_DIR/zoo.cfg"
Expand Down

0 comments on commit 6fea8be

Please sign in to comment.