11# TrinityProxy Makefile
22# Easy build and deployment for SOCKS5 proxy network
33
4- .PHONY : help build build-main build-dashboard build-dashboard-ui build-windows-agent build-darwin-agent build-linux-amd64 build-linux-arm64 install-agent-macos clean install deps test run-controller start-controller run-agent run-agent-dev docker-agent test-agent-docker docker-agent-down setup-dev check-deps format lint setup-system vps-setup setup-api-controller quickstart debug cleanup install-service install-dashboard-service install-production start-service stop-service start start-dev stop stop-production uninstall-production uninstall dashboard dashboard-dev dashboard-init dashboard-run dashboard-up run-dashboard sync-agent-key sync-deployment-settings setup-domain
4+ .PHONY : help build build-main build-dashboard build-dashboard-ui build-windows-agent build-darwin-agent build-linux-amd64 build-linux-arm64 install-agent-macos clean install deps test run-controller start-controller run-agent run-agent-dev docker-agent test-agent-docker docker-agent-down setup-dev check-deps format lint setup-system vps-setup setup-api-controller quickstart debug cleanup install-service install-dashboard-service install-production start-service stop-service start start-dev stop stop-production uninstall-production uninstall dashboard dashboard-dev dashboard-init dashboard-run dashboard-up run-dashboard sync-agent-key sync-deployment-settings setup-domain reset-dashboard-admin reset-dashboard-admin-dev fix-dev-permissions
55
66# Catch accidental "make run dashboard" (space) — the target is run-dashboard (hyphen).
77ifneq (,$(filter dashboard,$(MAKECMDGOALS ) ) )
@@ -25,12 +25,16 @@ help:
2525 @echo " TrinityProxy"
2626 @echo " ============"
2727 @echo " "
28- @echo " make start - PRODUCTION: install + run on VPS (deps, build, secrets, systemd)"
28+ @echo " make start - PRODUCTION (Linux VPS): install + run via systemd"
29+ @echo " On macOS: same as make start-dev (local only)"
2930 @echo " make uninstall-production - Remove prod install (systemd, /opt, data, config); fresh: sudo make start"
3031 @echo " make uninstall - Alias for uninstall-production"
3132 @echo " make setup-domain - VPS: interactive domain + Cloudflare wildcard SSL (sudo)"
3233 @echo " make start-dev - LOCAL DEV: Vite :8080, dashboard API :8081, controller :3100"
34+ @echo " Uses .dev/*.db — never touches production VPS"
3335 @echo " make stop - Stop local dev servers"
36+ @echo " make reset-dashboard-admin-dev - Reset admin login in .dev/dashboard.db (no sudo)"
37+ @echo " make fix-dev-permissions - Fix root-owned web/dashboard/dist after sudo make start"
3438 @echo " make run-agent-dev - macOS/local dev agent (embedded SOCKS :1080, foreground)"
3539 @echo " make build - Build all binaries"
3640
@@ -235,6 +239,21 @@ run: build
235239 @echo " [*] Starting TrinityProxy with interactive setup..."
236240 @export PATH=" /usr/local/go/bin:$$ PATH" ; ./$(BUILD_DIR ) /$(BINARY_NAME )
237241
242+ # Load dev or controller env for agent/controller targets
243+ define load-dev-env
244+ set -a; \
245+ if [ -f scripts/lib/dev-env.sh ]; then \
246+ . scripts/lib/dev-env.sh; \
247+ dev_env_apply; \
248+ if [ -f "$$DEV_CONTROLLER_ENV" ]; then \
249+ . "$$DEV_CONTROLLER_ENV"; \
250+ fi; \
251+ elif [ -f .env.controller ]; then \
252+ . ./.env.controller; \
253+ fi; \
254+ set +a;
255+ endef
256+
238257# Load .env.controller (TRINITY_AGENT_KEY) when present — written by make sync-agent-key
239258define load-controller-env
240259set -a; \
@@ -307,19 +326,11 @@ run-agent-dev: build-main
307326 @echo " "
308327 @echo " ============================================"
309328 @echo " macOS dev mode — embedded SOCKS on :1080 (no Dante)"
329+ @echo " LOCAL ONLY — heartbeats go to localhost"
310330 @echo " ============================================"
311331 @echo " "
312- @if [ -f .env.controller ]; then \
313- echo " [*] Loading .env.controller (TRINITY_AGENT_KEY)" ; \
314- else \
315- echo " [!] No .env.controller — run 'make sync-agent-key' after dashboard generates an agent key" ; \
316- fi
317- @echo " [*] Controller: $$ {CONTROLLER_URL:-http://127.0.0.1:3100}"
318- @echo " [*] SOCKS5: :$$ {TRINITY_SOCKS_PORT:-1080} (user=dev, pass=dev)"
319- @echo " [*] Press Ctrl+C to stop."
320- @echo " "
321332 @export PATH=" /usr/local/go/bin:$$ PATH" ; \
322- $(load-controller -env ) \
333+ $(load-dev -env ) \
323334 CONTROLLER_URL=" $$ {CONTROLLER_URL:-http://127.0.0.1:3100}" \
324335 TRINITY_ROLE=agent \
325336 TRINITY_DEV=1 \
@@ -386,7 +397,12 @@ dev-agent: build-main
386397 fi
387398
388399# Production — full VPS bootstrap (deps, build, secrets, systemd, credentials)
400+ # On macOS, delegates to start-dev (local only).
389401start :
402+ @if [ " $$ (uname -s)" = " Darwin" ]; then \
403+ echo " [*] macOS: make start runs LOCAL DEV (same as make start-dev)." ; \
404+ echo " [*] Do not use sudo. Production runs on your Linux VPS." ; \
405+ fi
390406 @chmod +x scripts/start-production.sh
391407 @./scripts/start-production.sh
392408
@@ -441,6 +457,17 @@ reset-dashboard-admin reset-admin:
441457 @chmod +x scripts/reset-dashboard-admin.sh scripts/lib/production-common.sh
442458 @./scripts/reset-dashboard-admin.sh
443459
460+
461+ # Fix root-owned dashboard UI dirs after accidental sudo make start (macOS local dev)
462+ fix-dev-permissions :
463+ @chmod +x scripts/fix-dev-permissions.sh scripts/lib/dev-ui-permissions.sh
464+ @./scripts/fix-dev-permissions.sh
465+
466+ # Reset admin in local dev database (.dev/dashboard.db) — no sudo
467+ reset-dashboard-admin-dev :
468+ @chmod +x scripts/reset-dashboard-admin.sh scripts/lib/production-common.sh
469+ @TRINITY_DEV=1 DASHBOARD_DB_PATH=" $( CURDIR) /.dev/dashboard.db" DASHBOARD_URL=" http://localhost:8080" ./scripts/reset-dashboard-admin.sh
470+
444471# Bootstrap initial dashboard admin (prints temp credentials once)
445472dashboard-init : build-dashboard
446473 @echo " [*] Initializing dashboard admin user..."
0 commit comments