#!/usr/bin/env bash # One-time (and re-runnable) server setup for Robot Clash. Run ON the server as root: # bash setup.sh [domain] default: roboclash.michael-media.de # Installs Node 24 + Caddy (auto-TLS), creates the service user, the release layout, the hardened systemd # service, the firewall and a daily DB backup. Migrates the old /opt/robotclash/{game,server} layout. # Afterwards deploy from your machine: bash server/deploy/deploy.sh --reset-db set -euo pipefail DOMAIN="${1:-roboclash.michael-media.de}" APP=/opt/robotclash SVC=robotclash echo ">> Robot Clash setup for $DOMAIN" # --- Node 24 LTS (Node 20 is end-of-life since 2026-04-30) ---------------------------------------- if ! node -v 2>/dev/null | grep -q '^v24\.'; then curl -fsSL https://deb.nodesource.com/setup_24.x | bash - apt-get install -y nodejs fi apt-get install -y build-essential python3 ufw sqlite3 curl # --- Caddy (reverse proxy + automatic HTTPS) ------------------------------------------------------ if ! command -v caddy >/dev/null 2>&1; then apt-get install -y debian-keyring debian-archive-keyring apt-transport-https gpg curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list >/dev/null apt-get update apt-get install -y caddy fi # --- service user + layout: releases/