feat: kit-connect + syno-balance SPK builds, busfleet hub registration endpoint

- kit-connect SPK (ipq806x): postinst with hub registration, start-stop-status,
  connect-daemon management, Tailscale + reverse SSH tunnel integration
- syno-balance SPK (noarch, test build): SmartWAN-aware dual-WAN load
  balancer with 6-factor scoring engine, syno-daemon lifecycle
- Busfleet hub: register.sh (port pool 2230-2299), Python HTTP server,
  systemd service, port-registry.json with x4078/x5925 assignments
- .gitignore: exclude SSH keys (*_id_ed25519), SPK artifacts (*.spk)

Gitea releases:
- kit-connect v0.1-0001 → x5925-kit-connect-v1 (production)
- syno-balance v0.1-0001 → syno-balance-test-v1 (prerelease)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-22 00:55:32 +00:00
parent f207c09920
commit 0c68fb2461
25 changed files with 501 additions and 0 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

+79
View File
@@ -0,0 +1,79 @@
#!/bin/sh
# build.sh — Assemble kit-connect SPK for Synology SRM (ipq806x)
# Output: kit-connect-0.1-0001.spk
#
# SPK structure (outer tar, UNCOMPRESSED):
# INFO
# PACKAGE_ICON.PNG (64x64)
# PACKAGE_ICON_256.PNG (256x256)
# scripts/
# postinst
# start-stop-status
# preinst
# preuninst
# postuninst
# conf/
# privilege
# resource
# package.tgz (gzipped inner tar of bin/ + conf/)
# checksum (md5 of package.tgz)
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$SCRIPT_DIR"
PKG_NAME="kit-connect"
VERSION="0.1-0001"
OUTPUT="${PKG_NAME}-${VERSION}.spk"
BUILD_DIR="/tmp/kit-connect-build-$$"
echo "=== Building ${PKG_NAME}-${VERSION}.spk ==="
# Clean and create build staging directory
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
# ── 1. Create inner package.tgz (gzipped tar of bin/ + conf/) ─────────
echo " → Creating package.tgz"
tar -czf "$BUILD_DIR/package.tgz" \
--format=ustar \
bin/ \
conf/connect.conf
# ── 2. Generate checksum ──────────────────────────────────────────────
echo " → Computing checksum"
md5sum "$BUILD_DIR/package.tgz" | awk '{print $1}' > "$BUILD_DIR/checksum"
# ── 3. Assemble outer SPK (UNCOMPRESSED tar) ──────────────────────────
echo " → Assembling SPK"
tar -cf "${OUTPUT}" \
--format=ustar \
-C "$SCRIPT_DIR" \
INFO \
PACKAGE_ICON.PNG \
PACKAGE_ICON_256.PNG \
scripts/ \
-C "$BUILD_DIR" \
package.tgz \
checksum
# SPK conf/ goes in the outer tar too
tar -rf "${OUTPUT}" \
--format=ustar \
-C "$SCRIPT_DIR" \
conf/privilege \
conf/resource
# ── 4. Verify ─────────────────────────────────────────────────────────
echo " → Verifying SPK contents"
tar -tf "${OUTPUT}" | sort
SIZE=$(stat -f%z "${OUTPUT}" 2>/dev/null || stat -c%s "${OUTPUT}" 2>/dev/null)
echo ""
echo "=== Build complete: ${OUTPUT} ==="
echo " Size: ${SIZE} bytes"
echo " MD5: $(md5sum "${OUTPUT}" | awk '{print $1}')"
# Cleanup
rm -rf "$BUILD_DIR"
+1
View File
@@ -0,0 +1 @@
{"defaults":{"run-as":"root"}}
+1
View File
@@ -0,0 +1 @@
{}
+43
View File
@@ -0,0 +1,43 @@
#!/bin/sh
# kit-connect postinst — register with hub, set up config
PKG_DIR="/var/packages/kit-connect/target"
CONF="/etc/kit-connect/connect.conf"
LOG_TAG="kit-connect"
log() { logger -t "$LOG_TAG" -p local0.warn "$*"; }
mkdir -p /etc/kit-connect "$PKG_DIR/var"
# If config doesn't exist, create from template
if [ ! -f "$CONF" ]; then
cp "$PKG_DIR/conf/connect.conf" "$CONF"
fi
# Prompt for device ID if not set
DEVICE_ID=$(cat /etc/busrouter/device-id 2>/dev/null || echo "")
if [ -z "$DEVICE_ID" ]; then
DEVICE_ID=$(hostname 2>/dev/null || echo "unknown")
fi
# Write device ID into config
sed -i "s/^DEVICE_ID=.*/DEVICE_ID=$DEVICE_ID/" "$CONF" 2>/dev/null
# Set hostname for Tailscale
sed -i "s/^TAILSCALE_HOSTNAME=.*/TAILSCALE_HOSTNAME=$DEVICE_ID/" "$CONF" 2>/dev/null
# Install tailscale binaries if not present
if [ ! -f /usr/local/bin/tailscale ]; then
if [ -f "$PKG_DIR/bin/tailscale" ]; then
cp "$PKG_DIR/bin/tailscale" "$PKG_DIR/bin/tailscaled" /usr/local/bin/ 2>/dev/null
chmod +x /usr/local/bin/tailscale /usr/local/bin/tailscaled 2>/dev/null
fi
fi
# Set key permissions
chmod 600 "$PKG_DIR/bin/connect_id_ed25519" 2>/dev/null
# Try hub registration (non-fatal — daemon retries)
curl -s --connect-timeout 10 "http://162.243.83.36:8080/api/register/${DEVICE_ID}" 2>/dev/null || true
log "postinst complete — device=${DEVICE_ID}"
exit 0
+2
View File
@@ -0,0 +1,2 @@
#!/bin/sh
exit 0
+2
View File
@@ -0,0 +1,2 @@
#!/bin/sh
exit 0
+2
View File
@@ -0,0 +1,2 @@
#!/bin/sh
exit 0
+35
View File
@@ -0,0 +1,35 @@
#!/bin/sh
PKG="kit-connect"
PKG_DIR="/var/packages/${PKG}/target"
DAEMON="${PKG_DIR}/bin/connect-daemon.sh"
DAEMON_PID="${PKG_DIR}/var/daemon.pid"
case "$1" in
start)
mkdir -p "${PKG_DIR}/var"
if [ -f "$DAEMON_PID" ] && kill -0 "$(cat "$DAEMON_PID")" 2>/dev/null; then
echo "Already running"
exit 0
fi
setsid "$DAEMON" &
echo $! > "$DAEMON_PID"
echo "Started"
;;
stop)
if [ -f "$DAEMON_PID" ]; then
kill "$(cat "$DAEMON_PID")" 2>/dev/null
sleep 1
kill -9 "$(cat "$DAEMON_PID")" 2>/dev/null
rm -f "$DAEMON_PID"
fi
echo "Stopped"
;;
status)
[ -f "$DAEMON_PID" ] && kill -0 "$(cat "$DAEMON_PID")" 2>/dev/null && exit 0
exit 1
;;
*)
echo "Usage: $0 {start|stop|status}"
;;
esac