bfa006f4ab
- SSH key management: generate ed25519 keypairs or import public keys from UI (/ssh-keys), per-machine key selection in Machines form, one-time private key download with hash verification - Fix engine to use machine-specific SSH key (was hardcoded to server key) - Job log persistence: write to job_logs table (DB) with batched inserts, buffer of 50 lines; GetAllFiltered with status/pair/date range filters - EventBus refactor: per-job subscriber channels, global channel, non-blocking - SSE endpoints: /jobs/stream (all), /jobs/:id/log/stream (per-job live) - JobDetail page: live log streaming, auto-scroll, cancel, duration - JobHistory: filters (pair, status, date range), pagination, link to detail - Cleanup scheduler: daily purge of job_logs and finished jobs older than SYNCSERVER_RETENTION_DAYS (default 30) - Migration 0002: indexes on job_logs(job_id), jobs(status,created_at), jobs(sync_pair_id)
50 lines
2.6 KiB
Makefile
50 lines
2.6 KiB
Makefile
BINARY=syncserver
|
|
VERSION?=1.0.5
|
|
GO?=go
|
|
LDFLAGS=-s -w -X main.version=$(VERSION) -X main.commit=$(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
|
|
BUILD_FLAGS=CGO_ENABLED=0
|
|
|
|
.PHONY: build build-all build-go frontend run package clean tidy test
|
|
|
|
frontend:
|
|
cd web && npm install && npm run build
|
|
|
|
build: frontend
|
|
cp -R web/dist internal/webui/dist
|
|
$(BUILD_FLAGS) $(GO) build -ldflags "$(LDFLAGS)" -o bin/$(BINARY) ./cmd/server
|
|
|
|
# build-go builds the binary without rebuilding the frontend (dist must exist).
|
|
build-go:
|
|
$(BUILD_FLAGS) $(GO) build -ldflags "$(LDFLAGS)" -o bin/$(BINARY) ./cmd/server
|
|
|
|
build-all: frontend
|
|
cp -R web/dist internal/webui/dist
|
|
$(BUILD_FLAGS) GOOS=linux GOARCH=amd64 $(GO) build -ldflags "$(LDFLAGS)" -o bin/$(BINARY)-linux-amd64 ./cmd/server
|
|
$(BUILD_FLAGS) GOOS=linux GOARCH=arm64 $(GO) build -ldflags "$(LDFLAGS)" -o bin/$(BINARY)-linux-arm64 ./cmd/server
|
|
|
|
run: build
|
|
SYNCSERVER_ADMIN_USER=admin SYNCSERVER_ADMIN_PASSWORD=secret \
|
|
SYNCSERVER_DATA_DIR=.data \
|
|
./bin/$(BINARY) --addr :8080
|
|
|
|
package: build-all
|
|
@mkdir -p dist/deb/usr/bin dist/deb/etc/syncserver dist/deb/lib/systemd/system dist/deb/DEBIAN
|
|
cp bin/$(BINARY)-linux-amd64 dist/deb/usr/bin/$(BINARY)
|
|
cp etc/syncserver/config.yaml dist/deb/etc/syncserver/config.yaml
|
|
cp lib/systemd/system/$(BINARY).service dist/deb/lib/systemd/system/$(BINARY).service
|
|
printf 'Package: $(BINARY)\nVersion: $(VERSION)\nSection: net\nPriority: optional\nArchitecture: amd64\nDepends: rsync, openssh-client, ca-certificates\nMaintainer: SyncServer\nDescription: File sync orchestrator with Wake-on-LAN and web UI\n' > dist/deb/DEBIAN/control
|
|
printf '#!/bin/sh\nset -e\nid $(BINARY) >/dev/null 2>&1 || useradd --system --no-create-home --shell /usr/sbin/nologin $(BINARY)\ninstall -d -o $(BINARY) -g $(BINARY) -m 0750 /var/lib/$(BINARY)/data\ninstall -d -o $(BINARY) -g $(BINARY) -m 0750 /var/lib/$(BINARY)/ssh\ninstall -d -o $(BINARY) -g $(BINARY) -m 0750 /var/lib/$(BINARY)/logs\ninstall -d -o root -g root -m 0755 /etc/$(BINARY)\n[ ! -f /etc/$(BINARY)/config.yaml ] && cp /etc/$(BINARY)/config.yaml /etc/$(BINARY)/config.yaml.new || true\nsystemctl daemon-reload 2>/dev/null || true\nsystemctl enable --now $(BINARY).service 2>/dev/null || true\n' > dist/deb/DEBIAN/postinst
|
|
chmod 0755 dist/deb/DEBIAN/postinst
|
|
printf '#!/bin/sh\nset -e\nsystemctl stop $(BINARY).service 2>/dev/null || true\nsystemctl disable $(BINARY).service 2>/dev/null || true\n' > dist/deb/DEBIAN/prerm
|
|
chmod 0755 dist/deb/DEBIAN/prerm
|
|
dpkg-deb --build dist/deb dist/$(BINARY)_$(VERSION)_amd64.deb
|
|
|
|
clean:
|
|
rm -rf bin dist .data web/node_modules web/dist internal/webui/dist
|
|
|
|
tidy:
|
|
$(GO) mod tidy
|
|
|
|
test:
|
|
$(GO) test ./...
|