Skip to content

Commit

Permalink
entrypoint: Check for required config files and use parameter expansi…
Browse files Browse the repository at this point in the history
…on (FIXUP)
  • Loading branch information
JeremyMcCormick committed Oct 1, 2024
1 parent 10340e9 commit 4d21bda
Showing 1 changed file with 27 additions and 36 deletions.
63 changes: 27 additions & 36 deletions docker/scripts/entrypoint-replication.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,41 +25,32 @@ echo "---- end ppdb-replication environment ----"
command -v ppdb-replication >/dev/null 2>&1 || { echo "ppdb-replication command not found"; exit 1; }
echo "Found ppdb-replication command"

_CMD="ppdb-replication"

if [ -n "$PPDB_REPLICATION_MON_LOGGER" ]; then
_CMD="$_CMD --mon-logger $PPDB_REPLICATION_MON_LOGGER"
fi

if [ -n "$PPDB_REPLICATION_MON_RULES" ]; then
_CMD="$_CMD --mon-rules $PPDB_REPLICATION_MON_RULES"
fi

_CMD="$_CMD run"

if [ "$PPDB_REPLICATION_UPDATE_EXISTING" = "true" ]; then
_CMD="$_CMD --update"
fi

if [ -n "$PPDB_REPLICATION_MIN_WAIT_TIME" ]; then
_CMD="$_CMD --min-wait-time $PPDB_REPLICATION_MIN_WAIT_TIME"
fi

if [ -n "$PPDB_REPLICATION_MAX_WAIT_TIME" ]; then
_CMD="$_CMD --max-wait-time $PPDB_REPLICATION_MAX_WAIT_TIME"
fi

if [ -n "$PPDB_REPLICATION_CHECK_INTERVAL" ]; then
_CMD="$_CMD --check-interval $PPDB_REPLICATION_CHECK_INTERVAL"
fi

if [ -n "$PPDB_REPLICATION_APDB_CONFIG" ]; then
_CMD="$_CMD $PPDB_REPLICATION_APDB_CONFIG"
fi

if [ -n "$PPDB_REPLICATION_PPDB_CONFIG" ]; then
_CMD="$_CMD $PPDB_REPLICATION_PPDB_CONFIG"
fi

# Check if required environment variables are set
if [ -z "${PPDB_REPLICATION_APDB_CONFIG:-}" ]; then
echo "PPDB_REPLICATION_APDB_CONFIG is a required environment variable"
exit 1
fi

if [ -z "${PPDB_REPLICATION_PPDB_CONFIG:-}" ]; then
echo "PPDB_REPLICATION_PPDB_CONFIG is a required environment variable"
exit 1
fi

# Build the command
_CMD=(
"ppdb-replication"
"${PPDB_REPLICATION_MON_LOGGER:+--mon-logger $PPDB_REPLICATION_MON_LOGGER}"
"${PPDB_REPLICATION_MON_RULES:+--mon-rules $PPDB_REPLICATION_MON_RULES}"
"run"
"${PPDB_REPLICATION_UPDATE_EXISTING:+$([ "$PPDB_REPLICATION_UPDATE_EXISTING" = "true" ] && echo --update)}"
"${PPDB_REPLICATION_MIN_WAIT_TIME:+--min-wait-time $PPDB_REPLICATION_MIN_WAIT_TIME}"
"${PPDB_REPLICATION_MAX_WAIT_TIME:+--max-wait-time $PPDB_REPLICATION_MAX_WAIT_TIME}"
"${PPDB_REPLICATION_CHECK_INTERVAL:+--check-interval $PPDB_REPLICATION_CHECK_INTERVAL}"
"${PPDB_REPLICATION_APDB_CONFIG}"
"${PPDB_REPLICATION_PPDB_CONFIG}"
)
_CMD=$(printf "%s " "${_CMD[@]}" | xargs)

# Run the command
echo "Running: $_CMD"
$_CMD

0 comments on commit 4d21bda

Please sign in to comment.