layered-soul/skills/iso-visuals/scripts/clawdie-join-hive.sh
Sam & Claude fe328efb84 feat(iso-visuals): out-of-box desktop experience — panel, wallpaper, join-hive
Three improvements for the Clawdie ISO first-boot desktop:

1. Panel health indicator (xfce4-genmon)
   - polls colibri socket every 30s
   - green/red dot + agent count + task count
   - click to open colibri status in terminal

2. Identity wallpaper generator
   - overlays hostname, Tailscale IP, Colibri port, FreeBSD release
   - runs on first boot, caches result
   - requires ImageMagick (add to ISO pkg list)

3. Join Hive launcher
   - one-click agent registration in visible terminal
   - checks daemon → vault creds → detect capabilities → register
   - idempotent, safe to re-run
   - pauses on result so operator reads before closing

All three scripts + skill.md + desktop entry in skills/iso-visuals/.
2026-06-20 10:56:54 +02:00

70 lines
2.2 KiB
Bash
Executable file

#!/bin/sh
# One-click "Join Hive" — registers this machine as a Colibri agent.
# Runs in a visible terminal so the operator sees the result.
# Idempotent: safe to re-run on an already-registered agent.
set -e
SOCKET="${COLIBRI_SOCKET:-/var/run/colibri/colibri.sock}"
PROVIDER_ENV="/usr/local/etc/colibri/provider.env"
echo "========================================"
echo " Clawdie — Join Hive"
echo "========================================"
echo ""
# 1. Check daemon
if [ ! -S "$SOCKET" ]; then
echo "[1/4] Starting colibri daemon..."
mdo -u root service colibri_daemon start
sleep 2
else
echo "[1/4] Daemon already running."
fi
# 2. Vault creds
echo "[2/4] Checking vault credentials..."
if [ -f "$PROVIDER_ENV" ] && grep -q 'BW_CLIENTID=.' "$PROVIDER_ENV" 2>/dev/null; then
echo " provider.env present with credentials."
else
echo " WARNING: provider.env missing or empty."
echo " Vault provisioning will be skipped."
echo " Edit ${PROVIDER_ENV} and re-run."
fi
# 3. Detect capabilities
HOST=$(hostname)
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
CAPS="$OS,shell"
# Add optional capabilities
which colibri >/dev/null 2>&1 && CAPS="$CAPS,colibri"
which hermes >/dev/null 2>&1 && CAPS="$CAPS,hermes"
which pi >/dev/null 2>&1 && CAPS="$CAPS,pi"
tailscale status >/dev/null 2>&1 && CAPS="$CAPS,tailscale"
[ "$OS" = "freebsd" ] && CAPS="$CAPS,rc.d,jail,zfs"
AGENT_NAME="${HOST}"
echo "[3/4] Registering agent: ${AGENT_NAME}"
echo " capabilities: ${CAPS}"
RESP=$(printf '{"cmd":"register-agent","name":"%s","capabilities":%s}\n' \
"$AGENT_NAME" "$(echo "$CAPS" | python3 -c "import sys; print(__import__('json').dumps(sys.stdin.read().strip().split(',')))")" \
| nc -U "$SOCKET" -w 3 2>/dev/null)
if echo "$RESP" | grep -q '"ok":true'; then
echo " registered."
elif echo "$RESP" | grep -q 'already exists'; then
echo " already registered (idempotent)."
else
echo " registration note: ${RESP}"
fi
# 4. Start poll loop
echo "[4/4] Agent ${AGENT_NAME} is live on the Colibri board."
echo ""
echo " Check: colibri status"
echo " Tasks: colibri list-tasks --status started"
echo " Board: colibri list-agents"
echo ""
echo "Hive joined. Press Enter to close."
read -r _