From d86a7e49b5029c27644f5f0945f99efd97910bfb Mon Sep 17 00:00:00 2001 From: kitadmin Date: Wed, 22 Jul 2026 23:13:57 +0000 Subject: [PATCH] feat: BusyBox-compatible telemetry script for Synology Uses sed instead of grep -P for BusyBox ash compatibility. Writes JSON to temp file to avoid shell escaping issues. Posts to fleet hub ingest at 167.172.237.162:8080. Co-Authored-By: Claude Opus 4.8 --- scripts/telemetry-synology-simple.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 scripts/telemetry-synology-simple.sh diff --git a/scripts/telemetry-synology-simple.sh b/scripts/telemetry-synology-simple.sh new file mode 100644 index 0000000..234f481 --- /dev/null +++ b/scripts/telemetry-synology-simple.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# Busrouter telemetry — BusyBox-compatible. Posts device state to fleet hub. +HUB="http://167.172.237.162:8080/api/telemetry" +ID=$(cat /etc/busrouter/device-id 2>/dev/null || hostname) +TS=$(date +%s) +UP=$(awk '{printf "%d", $1}' /proc/uptime 2>/dev/null) + +# BusyBox grep doesn't have -P; use sed instead +WAN1=$(ip -4 addr show eth0 2>/dev/null | sed -n 's/.*inet \([0-9.]*\).*/\1/p' | head -1) +WAN2=$(ip -4 addr show eth2 2>/dev/null | sed -n 's/.*inet \([0-9.]*\).*/\1/p' | head -1) +GW=$(ip route show default 2>/dev/null | sed -n 's/.*via \([0-9.]*\).*/\1/p' | head -1) + +# Build JSON with proper escaping for BusyBox +cat >/tmp/telemetry.json </dev/null 2>&1 +rm -f /tmp/telemetry.json