| ## ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| ## start.sh β Stealth Entrypoint | |
| ## ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| ## Starts 3 layers: | |
| ## 1. Tailscale daemon (userspace, no root) | |
| ## 2. Tailscale mesh join (background) | |
| ## 3. Uvicorn server on :7860 (foreground) | |
| ## ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| set -e | |
| echo "[BOOT] Starting stealth stack..." | |
| # ββ LAYER 3: Tailscale VPN (userspace mode) ββ | |
| # --tun=userspace-networking: No TUN device, no root β pure userspace sockets | |
| # --state: Persists auth in /tmp so reconnects survive container restarts | |
| # --socket: Unix socket for CLI communication (non-root writable path) | |
| echo "[TAILSCALE] Starting daemon in userspace mode..." | |
| tailscaled \ | |
| --tun=userspace-networking \ | |
| --state=/tmp/tailscale-state/tailscaled.state \ | |
| --socket=/tmp/tailscale-state/tailscaled.sock \ | |
| --no-logs-no-support \ | |
| &>/tmp/tailscale-state/daemon.log & | |
| TAILSCALED_PID=$! | |
| echo "[TAILSCALE] Daemon PID: ${TAILSCALED_PID}" | |
| # Wait for daemon socket to be ready | |
| sleep 3 | |
| # Authenticate and join the mesh network | |
| # TAILSCALE_AUTHKEY must be set as HF Space secret | |
| if [ -n "${TAILSCALE_AUTHKEY}" ]; then | |
| echo "[TAILSCALE] Joining mesh network..." | |
| tailscale up \ | |
| --authkey="${TAILSCALE_AUTHKEY}" \ | |
| --hostname=hf-stealth-node \ | |
| --accept-routes \ | |
| --socket=/tmp/tailscale-state/tailscaled.sock \ | |
| &>/tmp/tailscale-state/up.log & | |
| echo "[TAILSCALE] Mesh join initiated (background)" | |
| else | |
| echo "[TAILSCALE] No TAILSCALE_AUTHKEY set β VPN layer disabled (API still works via public URL)" | |
| fi | |
| # ββ LAYER 1 + 2: FastAPI Server (Decoy + Hidden API) ββ | |
| # uvicorn on 0.0.0.0:7860 β the ONLY exposed port | |
| # Process name shows as "python" + "uvicorn" β completely normal for HF | |
| echo "[SERVER] Starting on port 7860..." | |
| exec python3 -m uvicorn app:app --host 0.0.0.0 --port 7860 --log-level info | |