Skip to content

Commit 4d21bda

Browse files
entrypoint: Check for required config files and use parameter expansion (FIXUP)
1 parent 10340e9 commit 4d21bda

File tree

1 file changed

+27
-36
lines changed

1 file changed

+27
-36
lines changed

docker/scripts/entrypoint-replication.sh

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,32 @@ echo "---- end ppdb-replication environment ----"
2525
command -v ppdb-replication >/dev/null 2>&1 || { echo "ppdb-replication command not found"; exit 1; }
2626
echo "Found ppdb-replication command"
2727

28-
_CMD="ppdb-replication"
29-
30-
if [ -n "$PPDB_REPLICATION_MON_LOGGER" ]; then
31-
_CMD="$_CMD --mon-logger $PPDB_REPLICATION_MON_LOGGER"
32-
fi
33-
34-
if [ -n "$PPDB_REPLICATION_MON_RULES" ]; then
35-
_CMD="$_CMD --mon-rules $PPDB_REPLICATION_MON_RULES"
36-
fi
37-
38-
_CMD="$_CMD run"
39-
40-
if [ "$PPDB_REPLICATION_UPDATE_EXISTING" = "true" ]; then
41-
_CMD="$_CMD --update"
42-
fi
43-
44-
if [ -n "$PPDB_REPLICATION_MIN_WAIT_TIME" ]; then
45-
_CMD="$_CMD --min-wait-time $PPDB_REPLICATION_MIN_WAIT_TIME"
46-
fi
47-
48-
if [ -n "$PPDB_REPLICATION_MAX_WAIT_TIME" ]; then
49-
_CMD="$_CMD --max-wait-time $PPDB_REPLICATION_MAX_WAIT_TIME"
50-
fi
51-
52-
if [ -n "$PPDB_REPLICATION_CHECK_INTERVAL" ]; then
53-
_CMD="$_CMD --check-interval $PPDB_REPLICATION_CHECK_INTERVAL"
54-
fi
55-
56-
if [ -n "$PPDB_REPLICATION_APDB_CONFIG" ]; then
57-
_CMD="$_CMD $PPDB_REPLICATION_APDB_CONFIG"
58-
fi
59-
60-
if [ -n "$PPDB_REPLICATION_PPDB_CONFIG" ]; then
61-
_CMD="$_CMD $PPDB_REPLICATION_PPDB_CONFIG"
62-
fi
63-
28+
# Check if required environment variables are set
29+
if [ -z "${PPDB_REPLICATION_APDB_CONFIG:-}" ]; then
30+
echo "PPDB_REPLICATION_APDB_CONFIG is a required environment variable"
31+
exit 1
32+
fi
33+
34+
if [ -z "${PPDB_REPLICATION_PPDB_CONFIG:-}" ]; then
35+
echo "PPDB_REPLICATION_PPDB_CONFIG is a required environment variable"
36+
exit 1
37+
fi
38+
39+
# Build the command
40+
_CMD=(
41+
"ppdb-replication"
42+
"${PPDB_REPLICATION_MON_LOGGER:+--mon-logger $PPDB_REPLICATION_MON_LOGGER}"
43+
"${PPDB_REPLICATION_MON_RULES:+--mon-rules $PPDB_REPLICATION_MON_RULES}"
44+
"run"
45+
"${PPDB_REPLICATION_UPDATE_EXISTING:+$([ "$PPDB_REPLICATION_UPDATE_EXISTING" = "true" ] && echo --update)}"
46+
"${PPDB_REPLICATION_MIN_WAIT_TIME:+--min-wait-time $PPDB_REPLICATION_MIN_WAIT_TIME}"
47+
"${PPDB_REPLICATION_MAX_WAIT_TIME:+--max-wait-time $PPDB_REPLICATION_MAX_WAIT_TIME}"
48+
"${PPDB_REPLICATION_CHECK_INTERVAL:+--check-interval $PPDB_REPLICATION_CHECK_INTERVAL}"
49+
"${PPDB_REPLICATION_APDB_CONFIG}"
50+
"${PPDB_REPLICATION_PPDB_CONFIG}"
51+
)
52+
_CMD=$(printf "%s " "${_CMD[@]}" | xargs)
53+
54+
# Run the command
6455
echo "Running: $_CMD"
6556
$_CMD

0 commit comments

Comments
 (0)