feat: complete SyncServer implementation
Full-stack Go monolith with embedded React frontend for orchestrating rsync-over-SSH file synchronization with Wake-on-LAN support. Features: - JWT auth (HS256) with bcrypt password hashing - CRUD for machines (with WoL config) and sync_pairs - Ed25519 SSH key generation and known_hosts management - WoL magic packet sender + TCP-connect waiter with backoff - Sync engine: rsync subprocess, per-pair job queue, progress parsing - Homebrew cron parser for scheduled syncs - SSE stream for live job status (queued/waking_up/running/success/failed) - React+TS+Vite+Tailwind SPA embedded via embed.FS - Debian packaging with systemd unit, postinst/prerm/postrm Tech stack: - Go 1.22+ (CGO_ENABLED=0, pure SQLite via modernc.org/sqlite) - chi router for HTTP API - TypeScript + React 18 + Tailwind CSS frontend - Cross-compiled to Linux amd64 for Proxmox LXC deployment Tests: wol (MAC parsing, magic packet), syncengine/queue, scheduler/cron
This commit is contained in:
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
VERSION="${VERSION:-$(git describe --tags --always --dirty 2>/dev/null || echo dev)}"
|
||||
GOARCH="${GOARCH:-amd64}"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
|
||||
echo "=== Building SyncServer v${VERSION} for ${GOARCH} ==="
|
||||
|
||||
echo "=== Building frontend ==="
|
||||
cd "$PROJECT_DIR/web"
|
||||
npm ci --silent 2>/dev/null || npm install --silent
|
||||
npm run build
|
||||
|
||||
echo "=== Copying frontend dist to Go embed dir ==="
|
||||
rm -rf "$PROJECT_DIR/internal/webui/dist"
|
||||
cp -R "$PROJECT_DIR/web/dist" "$PROJECT_DIR/internal/webui/dist"
|
||||
|
||||
echo "=== Building Go binary ==="
|
||||
cd "$PROJECT_DIR"
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH="${GOARCH}" \
|
||||
go build -trimpath \
|
||||
-ldflags="-s -w -X main.version=${VERSION}" \
|
||||
-o "packaging/debian/usr/bin/syncserver" \
|
||||
./cmd/server
|
||||
|
||||
echo "=== Binary size ==="
|
||||
ls -lh "packaging/debian/usr/bin/syncserver"
|
||||
|
||||
echo "=== Done ==="
|
||||
echo "Run: ./scripts/package-deb.sh to create the .deb package"
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
VERSION="${VERSION:-$(git describe --tags --always --dirty 2>/dev/null || echo dev)}"
|
||||
ARCH="${ARCH:-amd64}"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
OUTPUT_DIR="$PROJECT_DIR/dist"
|
||||
DEB_DIR="$PROJECT_DIR/packaging/debian"
|
||||
|
||||
echo "=== Packaging SyncServer v${VERSION} for ${ARCH} ==="
|
||||
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
|
||||
DEB_PATH="$OUTPUT_DIR/syncserver_${VERSION}_${ARCH}.deb"
|
||||
|
||||
sed "s/@@VERSION@@/${VERSION}/" "$DEB_DIR/DEBIAN/control" > "$DEB_DIR/DEBIAN/control.tmp"
|
||||
mv "$DEB_DIR/DEBIAN/control.tmp" "$DEB_DIR/DEBIAN/control"
|
||||
|
||||
chmod 0755 "$DEB_DIR/DEBIAN/postinst"
|
||||
chmod 0755 "$DEB_DIR/DEBIAN/prerm"
|
||||
chmod 0755 "$DEB_DIR/DEBIAN/postrm"
|
||||
chmod 0644 "$DEB_DIR/DEBIAN/conffiles"
|
||||
chmod 0644 "$DEB_DIR/etc/syncserver/config.yaml"
|
||||
chmod 0644 "$DEB_DIR/lib/systemd/system/syncserver.service"
|
||||
|
||||
echo "=== Building .deb ==="
|
||||
dpkg-deb --build --root-owner-group "$DEB_DIR" "$DEB_PATH"
|
||||
|
||||
echo "=== Package info ==="
|
||||
dpkg-deb -I "$DEB_PATH"
|
||||
echo ""
|
||||
echo "=== Package contents (first 30) ==="
|
||||
dpkg-deb -c "$DEB_PATH" | head -30
|
||||
|
||||
echo ""
|
||||
echo "=== Output: $DEB_PATH ==="
|
||||
Reference in New Issue
Block a user