77 lines
2.3 KiB
Bash
Executable file
77 lines
2.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# One-command crew coordinator installer.
|
|
#
|
|
# curl -fsSL https://git.skate-spots.org/skatespots/SkateSpots/raw/branch/main/deploy/cordn/install.sh | bash
|
|
#
|
|
# Creates a persistent Cordn coordinator with SQLite storage, starts it, and
|
|
# prints the nprofile/add link when the server announces itself. The coordinator
|
|
# connects OUT to ContextVM relays; it needs no inbound port or TLS domain.
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")" 2>/dev/null || true
|
|
umask 077
|
|
|
|
need() { command -v "$1" >/dev/null || { echo "missing: $1" >&2; exit 1; }; }
|
|
need docker
|
|
need openssl
|
|
docker compose version >/dev/null 2>&1 || { echo "Docker Compose v2 is required (docker compose)." >&2; exit 1; }
|
|
|
|
if [ ! -f docker-compose.yml ]; then
|
|
cat > docker-compose.yml <<'YAML'
|
|
name: cordn
|
|
services:
|
|
cordn:
|
|
image: ghcr.io/cordn-msg/cordn:latest
|
|
container_name: cordn
|
|
restart: unless-stopped
|
|
env_file:
|
|
- .env
|
|
environment:
|
|
CORDN_STORAGE_BACKEND: sqlite
|
|
CORDN_SQLITE_PATH: /data/cordn.sqlite
|
|
volumes:
|
|
- cordn-data:/data
|
|
volumes:
|
|
cordn-data:
|
|
YAML
|
|
fi
|
|
|
|
if [ ! -f .env ]; then
|
|
NAME="${CORDN_SERVER_NAME:-skatespots-crew}"
|
|
RELAYS="${CORDN_RELAY_URLS:-wss://relay.contextvm.org,wss://relay2.contextvm.org}"
|
|
KEY="$(openssl rand -hex 32)"
|
|
cat > .env <<EOF
|
|
CORDN_SERVER_PRIVATE_KEY=$KEY
|
|
CORDN_RELAY_URLS=$RELAYS
|
|
CORDN_ANNOUNCED=true
|
|
CORDN_SERVER_NAME=$NAME
|
|
CORDN_STORAGE_BACKEND=sqlite
|
|
CORDN_SQLITE_PATH=/data/cordn.sqlite
|
|
CORDN_RATE_LIMIT_ENABLED=true
|
|
CORDN_RATE_LIMIT_REFILL_PER_MINUTE=250
|
|
CORDN_RATE_LIMIT_BURST=80
|
|
CORDN_MAX_KEY_PACKAGES_PER_IDENTITY=50
|
|
CORDN_MAX_LAST_RESORT_KEY_PACKAGES_PER_IDENTITY=1
|
|
EOF
|
|
chmod 600 .env
|
|
echo "Generated .env (keep it private; it contains the coordinator key)."
|
|
fi
|
|
|
|
docker compose up -d
|
|
echo "Waiting for the coordinator to announce itself…"
|
|
|
|
for _ in $(seq 1 30); do
|
|
logs="$(docker compose logs --no-color 2>&1 || true)"
|
|
if printf '%s\n' "$logs" | grep -q 'nprofile'; then
|
|
printf '\n%s\n' "$logs" | grep -A12 -B2 'CORDN COORDINATOR'
|
|
echo
|
|
echo "Back up .env and the cordn-data volume before inviting the crew."
|
|
echo "Adopt it in SkateSpots: Settings → Coordinator, or Crew edit → Coordinator."
|
|
exit 0
|
|
fi
|
|
sleep 2
|
|
done
|
|
|
|
echo "The container started but no announcement appeared within 60s." >&2
|
|
echo "Inspect: docker compose logs --no-color" >&2
|
|
exit 1
|