Stage 3-5 server (military, expansion, social), web client for stages 1-2, ops/deploy

Built: units/research/training, movements (scan, raid, attack, takeover, reinforce, settle, transport), deterministic
combat resolved in the event queue, reports, power/offline units, founding + conquest + incumbent sites; alliances,
roles, diplomacy (24h pact cancel via events), messages, rankings; vanilla-JS phone-first client (auth, POP, map,
alerts, settings, en/nb); systemd units, backup timer, DEPLOY.md, tools/admin.js.
Tested: npm test 96/96 (fake clock, in-memory db, a few real-HTTP tests); client checked with headless Chromium
screenshots only. NOT done: marketplace/transport trade, client screens for military/social, WebSocket push,
bots/balance, e2e suite. All unit stats and costs are unbalanced first guesses.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q2MJaQ5LXAHzGnTDgceT14
This commit is contained in:
jvanvik 2026-10-11 18:32:36 +02:00
parent b56b13880e
commit 249818a7aa
111 changed files with 17472 additions and 13 deletions

21
deploy/upstream-admin Executable file
View file

@ -0,0 +1,21 @@
#!/bin/sh
# Run tools/admin.js as the service user, against the service's database. Install:
# install -m 0755 /opt/upstream/deploy/upstream-admin /usr/local/bin/upstream-admin
# upstream-admin help
# Running admin.js as root would create the database's -wal/-shm files owned by root and the game could no longer open
# the database, hence the runuser. DB_PATH comes from the environment, else /etc/upstream/upstream.env, else the default.
set -eu
APP_DIR=${UPSTREAM_DIR:-/opt/upstream}
ENV_FILE=${UPSTREAM_ENV_FILE:-/etc/upstream/upstream.env}
if [ -z "${DB_PATH:-}" ] && [ -r "$ENV_FILE" ]; then
DB_PATH=$(sed -n 's/^[[:space:]]*DB_PATH=//p' "$ENV_FILE" | tail -n 1 | sed -e 's/^"\(.*\)"$/\1/' -e "s/^'\(.*\)'\$/\1/")
fi
DB_PATH=${DB_PATH:-/var/lib/upstream/game.db}
if [ "$(id -u)" = 0 ]; then
exec runuser -u upstream -- env DB_PATH="$DB_PATH" node "$APP_DIR/tools/admin.js" "$@"
elif [ "$(id -un)" = upstream ]; then
exec env DB_PATH="$DB_PATH" node "$APP_DIR/tools/admin.js" "$@"
else
echo "upstream-admin: run as root (it switches to the upstream user) or as the upstream user" >&2
exit 2
fi