#!/usr/bin/env bash # Run ONCE, on the worker node only (beta — the old VPS). Joins the Swarm # initialized by init-swarm.sh on the manager, over the WireGuard tunnel. set -euo pipefail MANAGER_WG_IP="${1:?usage: $0 }" JOIN_TOKEN="${2:?}" if docker info 2>/dev/null | grep -q "Swarm: active"; then echo "This node is already part of a swarm:" docker info 2>/dev/null | grep -A2 "Swarm:" exit 0 fi docker swarm join --token "$JOIN_TOKEN" "${MANAGER_WG_IP}:2377" echo echo "Joined. Verify from the manager: docker node ls"