Files
edubox/agent/build.sh
T
EduBox Dev e946b22a42 feat(agent): v0.3.9 sync, UI details, self-update, centralized version
- Add agent/server startup sync (sync/sync_response)
- Centralize agent version in agent/VERSION + expose /api/agent/version
- Display agent version, nodeId and server version in local UI
- Add agent self-update detection/download/restart via helper scripts
- Run start/stop/delete/reset handlers in goroutines to avoid WebSocket blocking
- Update dashboard download links and SUIVI_VPN_ONDEMAND.md
- Document Podman stays installer-managed, not agent-updated
2026-06-27 21:11:20 +00:00

90 lines
3.3 KiB
Bash
Executable File

#!/bin/bash
set -e
VERSION="$(cat "$(dirname "$0")/VERSION")"
APP_NAME="studioE5"
BIN_NAME="studioE5-agent"
LDFLAGS="-X main.version=${VERSION}"
# On Windows, build a GUI binary so no console window opens on double-click.
WIN_LDFLAGS="${LDFLAGS} -H windowsgui"
echo "Building ${APP_NAME} Agent v${VERSION}..."
export PATH=$PATH:/usr/local/go/bin
GOOS=windows GOARCH=amd64 go build -ldflags "${WIN_LDFLAGS}" -o ${BIN_NAME}.exe .
echo " ${BIN_NAME}.exe (Windows amd64)"
cp ${BIN_NAME}.exe "${BIN_NAME}-v${VERSION}.exe"
echo " ${BIN_NAME}-v${VERSION}.exe (Windows amd64)"
GOOS=linux GOARCH=amd64 go build -ldflags "${LDFLAGS}" -o ${BIN_NAME} .
echo " ${BIN_NAME} (Linux amd64)"
cp ${BIN_NAME} "${BIN_NAME}-v${VERSION}"
echo " ${BIN_NAME}-v${VERSION} (Linux amd64)"
# macOS build requires CGO for the systray menu; skip gracefully if unavailable.
if GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -ldflags "${LDFLAGS}" -o ${BIN_NAME}-mac . 2>/dev/null; then
echo " ${BIN_NAME}-mac (macOS amd64)"
cp ${BIN_NAME}-mac "${BIN_NAME}-v${VERSION}-mac"
echo " ${BIN_NAME}-v${VERSION}-mac (macOS amd64)"
MAC_BUILT=1
else
echo " ${BIN_NAME}-mac (macOS amd64) - skipped, CGO required for systray"
MAC_BUILT=0
fi
# Build Windows distribution zip (agent + Tailscale binaries)
ZIP_NAME="${BIN_NAME}-v${VERSION}-windows.zip"
if [ -d "tailscale-bin/windows" ]; then
python3 - <<PY
import zipfile, os
with zipfile.ZipFile("${ZIP_NAME}", 'w', zipfile.ZIP_DEFLATED) as zf:
zf.write("${BIN_NAME}.exe", "${BIN_NAME}.exe")
for f in ["tailscale.exe", "tailscaled.exe", "wintun.dll"]:
zf.write(f"tailscale-bin/windows/{f}", f"tailscale-bin/windows/{f}")
readme = r"""${APP_NAME} Agent - Windows
=======================
1. Extract this archive to a folder (e.g. C:\${APP_NAME}-agent).
2. Create a data folder (e.g. C:\${APP_NAME}-agent\data).
3. Create the config file data\${BIN_NAME}-config.json:
{
"server": "wss://studioe5.edudeploy.com/api/websocket",
"headscale_url": "https://headscale.studioe5.edudeploy.com",
"headscale_auth_key": "YOUR_PREAUTH_KEY",
"node_id": "YOUR_NODE_ID",
"data_dir": "C:\\${APP_NAME}-agent\\data"
}
4. Run the agent:
${BIN_NAME}.exe -no-tray -data-dir C:\${APP_NAME}-agent\data
Tailscale binaries (tailscale.exe, tailscaled.exe, wintun.dll) are bundled
in tailscale-bin\windows\ and used automatically by the agent.
"""
zf.writestr("README-Windows.txt", readme)
print(f" ${ZIP_NAME}")
PY
else
echo " Warning: tailscale-bin/windows not found, run ./download-tailscale-bins.sh first"
fi
# Copy versioned binaries to server/public so the dashboard can serve them
SERVER_PUBLIC="../server/public"
if [ -d "${SERVER_PUBLIC}" ]; then
cp "${BIN_NAME}-v${VERSION}" "${SERVER_PUBLIC}/${BIN_NAME}-v${VERSION}"
cp "${BIN_NAME}-v${VERSION}.exe" "${SERVER_PUBLIC}/${BIN_NAME}-v${VERSION}.exe"
if [ "$MAC_BUILT" = "1" ]; then
cp "${BIN_NAME}-v${VERSION}-mac" "${SERVER_PUBLIC}/${BIN_NAME}-v${VERSION}-mac"
fi
if [ -f "${ZIP_NAME}" ]; then
cp "${ZIP_NAME}" "${SERVER_PUBLIC}/${ZIP_NAME}"
fi
echo " Copied versioned binaries to ${SERVER_PUBLIC}"
fi
echo ""
echo "Download URLs (once served by Caddy):"
echo " https://studioe5.edudeploy.com/${BIN_NAME}-v${VERSION}.exe"
echo " https://studioe5.edudeploy.com/${ZIP_NAME}"
echo "Done."