27 lines
802 B
Bash
27 lines
802 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Entrypoint: write `MAVEN_SETTINGS` or decode `MAVEN_SETTINGS_BASE64`
|
|
# into ~/.m2/settings.xml (MAVEN_SETTINGS_BASE64 takes precedence),
|
|
# then exec the container command.
|
|
|
|
M2_DIR="${HOME:-/root}/.m2"
|
|
|
|
if [[ -n "${MAVEN_SETTINGS_BASE64:-}" ]]; then
|
|
mkdir -p "$M2_DIR"
|
|
# Decode base64 content and write it. If decoding fails the script will error.
|
|
printf '%s' "$MAVEN_SETTINGS_BASE64" | base64 -d > "$M2_DIR/settings.xml"
|
|
chmod 644 "$M2_DIR/settings.xml" || true
|
|
elif [[ -n "${MAVEN_SETTINGS:-}" ]]; then
|
|
mkdir -p "$M2_DIR"
|
|
# Write the variable contents exactly as provided
|
|
printf '%s' "$MAVEN_SETTINGS" > "$M2_DIR/settings.xml"
|
|
chmod 644 "$M2_DIR/settings.xml" || true
|
|
fi
|
|
|
|
if [[ "$#" -eq 0 ]]; then
|
|
exec "$SHELL" || exec /bin/sh
|
|
fi
|
|
|
|
exec "$@"
|