Add Go agent OpenWrt service package

This commit is contained in:
benya
2026-06-05 13:54:43 +03:00
parent 3e20beb7f3
commit ca8b001991
7 changed files with 165 additions and 1 deletions
+40
View File
@@ -0,0 +1,40 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=rmm-agent-go
PKG_VERSION:=0.5.0
PKG_RELEASE:=1
PKG_MAINTAINER:=RMM OpenWrt
PKG_LICENSE:=MIT
include $(INCLUDE_DIR)/package.mk
define Package/rmm-agent-go
SECTION:=admin
CATEGORY:=Administration
TITLE:=OpenWrt RMM Go agent
DEPENDS:=+ca-bundle +ip-tiny +iwinfo +openssh-client +openssh-keygen
endef
define Package/rmm-agent-go/description
Go implementation of the outbound polling agent for OpenWrt RMM.
endef
define Build/Compile
[ -x ./files/usr/bin/rmm-agent-go ]
endef
define Package/rmm-agent-go/conffiles
/etc/rmm-agent-go.conf
endef
define Package/rmm-agent-go/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) ./files/usr/bin/rmm-agent-go $(1)/usr/bin/rmm-agent-go
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/etc/init.d/rmm-agent-go $(1)/etc/init.d/rmm-agent-go
$(INSTALL_DIR) $(1)/etc
$(INSTALL_CONF) ./files/etc/rmm-agent-go.conf $(1)/etc/rmm-agent-go.conf
endef
$(eval $(call BuildPackage,rmm-agent-go))
+37
View File
@@ -0,0 +1,37 @@
# rmm-agent-go OpenWrt Package
OpenWrt package skeleton for the Go agent.
## Buildroot Usage
Cross-build the Go binary for the router target first and place it into the package-local files directory:
```sh
mkdir -p agent/package/rmm-agent-go/files/usr/bin
GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -trimpath -ldflags="-s -w" -o agent/package/rmm-agent-go/files/usr/bin/rmm-agent-go ./agent/go/cmd/rmm-agent
```
Copy or symlink this directory into an OpenWrt buildroot package path:
```sh
cp -R agent/package/rmm-agent-go /path/to/openwrt/package/rmm-agent-go
cd /path/to/openwrt
make package/rmm-agent-go/compile V=s
```
Then install the generated `.ipk` on a router:
```sh
opkg install /tmp/rmm-agent-go_*.ipk
vi /etc/rmm-agent-go.conf
/etc/init.d/rmm-agent-go enable
/etc/init.d/rmm-agent-go start
```
## Installed Files
- `/usr/bin/rmm-agent-go`
- `/etc/init.d/rmm-agent-go`
- `/etc/rmm-agent-go.conf`
The package intentionally keeps a separate config and service name so it can run side by side with the shell agent during migration.
@@ -0,0 +1,23 @@
#!/bin/sh /etc/rc.common
START=95
STOP=10
USE_PROCD=1
PROG=/usr/bin/rmm-agent-go
CONFIG_FILE=/etc/rmm-agent-go.conf
start_service() {
procd_open_instance
procd_set_param command "$PROG" -config "$CONFIG_FILE"
procd_set_param stdout 1
procd_set_param stderr 1
procd_set_param term_timeout 15
procd_set_param respawn 3600 5 5
procd_close_instance
}
stop_service() {
service_stop "$PROG"
rm -rf /tmp/rmm-agent-go.lock
}
@@ -0,0 +1,12 @@
SERVER_URL="http://127.0.0.1:8080"
ENROLLMENT_TOKEN="dev-enroll-token"
INTERVAL_SECONDS="30"
CHECK_TARGETS="1.1.1.1 8.8.8.8"
TUNNEL_IDENTITY_FILE="/etc/rmm-agent/tunnel_key"
LOCK_FILE="/tmp/rmm-agent-go.lock"
SPOOL_DIR="/tmp/rmm-agent-go-results"
BACKUP_DIR="/tmp/rmm-agent-go-backups"
TUNNEL_STATE_DIR="/tmp/rmm-agent-go-tunnels"
HOSTNAME_SUFFIX="-go"
DEVICE_ID=""
DEVICE_TOKEN=""