Skip to content

Commit

Permalink
fix: add condition in case vars are undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
apham0001 authored and OisinKyne committed Feb 4, 2025
1 parent 85929a9 commit 133e8c7
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions promtail/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ if [ -z "$CHARON_LOKI_ADDRESSES" ]; then
exit 1
fi

sed "s|\$CHARON_LOKI_ADDRESSES|${CHARON_LOKI_ADDRESSES}|g" \
/etc/promtail/config.yml.example > /etc/promtail/config.yml
if [ -z "$CLUSTER_NAME" ]; then
echo "Error: \$CLUSTER_NAME variable is empty" >&2
exit 1
fi

sed "s|\$CLUSTER_NAME|${CLUSTER_NAME}|g" \
/etc/promtail/config.yml.example > /etc/promtail/config.yml
if [ -z "$CLUSTER_PEER" ]; then
echo "Error: \$CLUSTER_PEER variable is empty" >&2
exit 1
fi

sed "s|\$CLUSTER_PEER|${CLUSTER_PEER}|g" \
# Process the template file once
sed -e "s|\$CHARON_LOKI_ADDRESSES|${CHARON_LOKI_ADDRESSES}|g" \
-e "s|\$CLUSTER_NAME|${CLUSTER_NAME}|g" \
-e "s|\$CLUSTER_PEER|${CLUSTER_PEER}|g" \
/etc/promtail/config.yml.example > /etc/promtail/config.yml

# Start Promtail with the generated config
Expand Down

0 comments on commit 133e8c7

Please sign in to comment.