Skip to content

Commit

Permalink
Fix metrics envs
Browse files Browse the repository at this point in the history
  • Loading branch information
dappnodedev committed Sep 17, 2024
1 parent f5fcb5f commit af378a7
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions metrics/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ update_user_setting() {

if [ -z "$value" ]; then
echo "[INFO | metrics] Skipped updating $key in user settings file (empty value)"
return 1
return 0
fi

if grep -q "^$key=" "$USER_SETTINGS_FILE"; then
Expand All @@ -33,7 +33,7 @@ update_user_setting() {
fi
}

source_envs() {
source_assets_envs() {
set -a # Export all variables

# shellcheck disable=SC1091
Expand All @@ -49,12 +49,19 @@ source_envs() {
_ASSETS_VERSION="$(cat /assets/version)"
fi

# shellcheck disable=SC1090
. "$USER_SETTINGS_FILE"

set +a
}

source_user_settings() {
# Ensure user settings file exists
if [ -f "$USER_SETTINGS_FILE" ]; then
set -a
# shellcheck disable=SC1090
. "$USER_SETTINGS_FILE"
set +a
fi
}

replace_envs_in_yaml() {
echo "[INFO | metrics] Replacing environment variables in the configuration file"
sed "s|%{KEYPER_NAME}|$KEYPER_NAME|g; s|%{_ASSETS_VERSION}|$_ASSETS_VERSION|g" "$TEMPLATE_CONFIG_FILE" >"$CONFIG_FILE"
Expand All @@ -67,7 +74,9 @@ if [ "${SHUTTER_PUSH_METRICS_ENABLED}" = "false" ]; then
exit 0
fi

source_envs
source_assets_envs

source_user_settings

replace_envs_in_yaml

Expand Down

0 comments on commit af378a7

Please sign in to comment.