diff --git a/make-classic.sh b/make-classic.sh index 99bf427..b85dbda 100755 --- a/make-classic.sh +++ b/make-classic.sh @@ -6,8 +6,4 @@ sed -i 's/CRAFT_PART_INSTALL/SNAPCRAFT_PART_INSTALL/g' snap/snapcraft.yaml sed -i '/libbpfcc/d' snap/snapcraft.yaml sed -i '/bpfcc-tools/d' snap/snapcraft.yaml yq -i 'del(.apps.grafana-agent.plugs) | del(.plugs)' snap/snapcraft.yaml -cat << "EOF" > snap/local/agent-wrapper -#!/bin/sh - -exec "${SNAP}/agent" -config.expand-env -config.file "/etc/grafana-agent.yaml" -EOF +sed -i 's/agent-wrapper.strict/agent-wrapper.classic/g' snap/snapcraft.yaml diff --git a/snap/local/agent-wrapper.classic b/snap/local/agent-wrapper.classic new file mode 100755 index 0000000..b92c7eb --- /dev/null +++ b/snap/local/agent-wrapper.classic @@ -0,0 +1,12 @@ +#!/bin/sh + +if [ "$(snapctl get reporting-enabled)" = "0" ] +then + echo "Launched with reporting disabled" | systemd-cat + REPORTING_ARG="-disable-reporting" +else + echo "Launched with reporting enabled" | systemd-cat + REPORTING_ARG="" +fi + +exec "${SNAP}/agent" -config.expand-env -config.file "${CONFIG_FILE}" "${REPORTING_ARG}" diff --git a/snap/local/agent-wrapper b/snap/local/agent-wrapper.strict similarity index 100% rename from snap/local/agent-wrapper rename to snap/local/agent-wrapper.strict diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 89ab43a..657e43b 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -51,7 +51,7 @@ parts: source: ./snap/local source-type: local override-build: | - cp agent-wrapper $CRAFT_PART_INSTALL/ + cp agent-wrapper.strict $CRAFT_PART_INSTALL/agent-wrapper grafana-agent: plugin: go source: https://github.com/grafana/agent