#!/usr/bin/env bash set -euo pipefail dir="$(mktemp -d)" pushd . cd "${dir}" BINARY=$(curl https://api.github.com/repos/prometheus/node_exporter/releases/latest | jq -r '.assets[] | select(.name | contains("linux-amd64")) | .browser_download_url') curl -L $BINARY -o node-exporter.tgz mkdir -p prometheus/usr/{bin,lib/{systemd/system,extension-release.d}} tar xzf node-exporter.tgz cp -vrf node_exporter-*/node_exporter prometheus/usr/bin/node_exporter cat > /etc/systemd/system/prometheus-node-exporter.service <<- EOM [Unit] Description=Prometheus exporter for machine metrics Requires=network-online.target After=network-online.target [Service] Restart=on-failure ExecStart=/usr/bin/node_exporter ExecReload=/bin/kill -HUP \$MAINPID NoNewPrivileges=true ProtectHome=read-only ProtectSystem=strict [Install] WantedBy=multi-user.target EOM source /etc/os-release echo -e "SYSEXT_LEVEL=1.0\nID=steamos\nVERSION_ID=${VERSION_ID}" >> prometheus/usr/lib/extension-release.d/extension-release.prometheus-node-exporter mkdir -p /var/lib/extensions rm -rf /var/lib/extensions/prometheus-node-exporter cp -vrf prometheus /var/lib/extensions/prometheus-node-exporter popd rm -rf "${dir}"