a414f03a59
- Configure tailscale serve automatically for each instance on Windows userspace networking. - Add local UI buttons: start/stop/reset/delete instances (stop/start preserve volumes). - Clean shutdown: stop tailscaled and instances, notify server with instance_stopped. - Restart tailscaled on agent boot using persisted state when pre-auth key is absent. - Sync instance stopped/deleted status to dashboard (server/lib/websocket.ts). - Security: include prior authz/scoping changes across API routes, ephemeral pre-auth keys, ACL policy, internal API key. - Update SUIVI_VPN_ONDEMAND.md and docs/ONBOARDING_CLIENT.md. - Bump agent version to 0.3.5.
90 lines
3.3 KiB
Bash
Executable File
90 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
VERSION="0.3.5"
|
|
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."
|