From 50ce5a25ee7f8a97a88d0eda18188c88e745f778 Mon Sep 17 00:00:00 2001 From: William Petit Date: Fri, 13 Oct 2023 12:29:51 +0200 Subject: [PATCH] feat: sentry integration --- install/emissary-files.mk | 2 ++ misc/emissary/config/emissary | 4 +++- misc/emissary/init.d/emissary-agent | 4 +++- misc/emissary/uci-defaults/99-emissary.sh | 6 ++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/install/emissary-files.mk b/install/emissary-files.mk index eb94916..153ef0a 100644 --- a/install/emissary-files.mk +++ b/install/emissary-files.mk @@ -31,6 +31,8 @@ install-emissary-files: tools/yq/bin/yq tools/upx/bin/upx tools/yq/bin/yq -i '.agent.controllers.sysupgrade.firmwareVersionCommand = ["sh", "-c", "source /etc/emissary_firmware && echo \"$$FIRMWARE_VERSION\""]' files/etc/emissary/agent.yml tools/yq/bin/yq -i '.agent.controllers.app.dataDir = "/data/emissary/apps/data"' files/etc/emissary/agent.yml tools/yq/bin/yq -i '.agent.controllers.app.downloadDir = "/data/emissary/apps/bundles"' files/etc/emissary/agent.yml + tools/yq/bin/yq -i '.sentry.dsn = "$${EMISSARY_SENTRY_DSN}"' files/etc/emissary/agent.yml + tools/yq/bin/yq -i '.sentry.environment = "$${EMISSARY_SENTRY_ENVIRONMENT}"' files/etc/emissary/agent.yml # Copy emissary binary mkdir -p files/usr/local/bin diff --git a/misc/emissary/config/emissary b/misc/emissary/config/emissary index a262cc9..4d82876 100644 --- a/misc/emissary/config/emissary +++ b/misc/emissary/config/emissary @@ -2,4 +2,6 @@ package emissary config main 'agent' option reconciliation_interval '60' - option server_url 'https://emissary.cadol.es' \ No newline at end of file + option server_url 'https://emissary.cadol.es' + option sentry_dsn '' + option sentry_environment '' \ No newline at end of file diff --git a/misc/emissary/init.d/emissary-agent b/misc/emissary/init.d/emissary-agent index 4a8c176..2195269 100755 --- a/misc/emissary/init.d/emissary-agent +++ b/misc/emissary/init.d/emissary-agent @@ -12,10 +12,12 @@ start_service() { config_get emissary_reconciliation_interval agent 'reconciliation_interval' "60" config_get emissary_server_url agent 'server_url' "https://emissary.cadol.es" + config_get emissary_sentry_dsn agent 'sentry_dsn' "" + config_get emissary_sentry_environment agent 'sentry_environment' "" local config_file="/etc/emissary/agent.yml" procd_open_instance emissary-agent - procd_set_param env EMISSARY_SERVER_URL="$emissary_server_url" EMISSARY_RECONCILIATION_INTERVAL="$emissary_reconciliation_interval" + procd_set_param env EMISSARY_SERVER_URL="$emissary_server_url" EMISSARY_RECONCILIATION_INTERVAL="$emissary_reconciliation_interval" EMISSARY_SENTRY_DSN="$emissary_sentry_dsn" EMISSARY_SENTRY_ENVIRONMENT="$emissary_sentry_environment" procd_set_param command /usr/local/bin/emissary procd_append_param command --workdir /usr/share/emissary procd_append_param command --config "$config_file" diff --git a/misc/emissary/uci-defaults/99-emissary.sh b/misc/emissary/uci-defaults/99-emissary.sh index c8f27e6..aaa96b1 100644 --- a/misc/emissary/uci-defaults/99-emissary.sh +++ b/misc/emissary/uci-defaults/99-emissary.sh @@ -17,6 +17,12 @@ main() { if [ ! -z "${EMISSARY_SERVER_URL}" ]; then uci set "emissary.agent.server_url=${EMISSARY_SERVER_URL}" fi + if [ ! -z "${EMISSARY_SENTRY_DSN}" ]; then + uci set "emissary.agent.sentry_dsn=${EMISSARY_SENTRY_DSN}" + fi + if [ ! -z "${EMISSARY_SENTRY_ENVIRONMENT}" ]; then + uci set "emissary.agent.sentry_environment=${EMISSARY_SENTRY_ENVIRONMENT}" + fi # Commit modifications uci commit