27 lines
642 B
Bash
27 lines
642 B
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
echo "++ running new entrypoint"
|
|
ORIGINAL_ENTRYPOINT="$1"
|
|
shift
|
|
|
|
echo "++ original entrypoint: ${ORIGINAL_ENTRYPOINT}"
|
|
|
|
# --- Load secrets into environment variables ---
|
|
if [ -d /run/secrets ]; then
|
|
for secret_file in /run/secrets/*; do
|
|
echo "++ loading secret: ${secret_file}"
|
|
var_name=$(basename "$secret_file" | tr '[:lower:]' '[:upper:]')
|
|
export "$var_name"="$(cat "$secret_file")"
|
|
done
|
|
fi
|
|
|
|
echo "++ command: ${@}"
|
|
|
|
# --- Execute the original entrypoint and command ---
|
|
if [ -n "$ORIGINAL_ENTRYPOINT" ] && [ "$ORIGINAL_ENTRYPOINT" != "null" ]; then
|
|
exec "$ORIGINAL_ENTRYPOINT" "$@"
|
|
else
|
|
exec "$@"
|
|
fi
|