diff --git a/make-classic.sh b/make-classic.sh index 99bf427..22f3f6e 100755 --- a/make-classic.sh +++ b/make-classic.sh @@ -1,13 +1,11 @@ #!/bin/sh +# The classic snap needs to be built on core20 because of libc6 dependency: +# A core22 snap needs glibc 2.32+, but in a 20.04 charm we have glibc 2.31. sed -i 's/base: core22/base: core20/g' snap/snapcraft.yaml sed -i 's/confinement: strict/confinement: classic/g' snap/snapcraft.yaml 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..b4d7907 --- /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 "/etc/grafana-agent.yaml" "${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