diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 6a444b6b..f46fb11c 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -39,7 +39,7 @@ jobs:
- name: Check
run: >-
./gradlew --console=plain
- :core:check :game:check :tools:check :terminal:check :web-common:check
+ :core:check :game:check :tools:check :web-common:check
:runtime:check :runtime-web:check :runtime-bitmap-web:check
- name: Upload test reports
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 26e3da8c..c8465549 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -147,12 +147,12 @@ jobs:
uses: docker/build-push-action@v7
with:
context: .
- file: deploy/docker/Dockerfile.bitmap-production
+ file: deploy/docker/Dockerfile.bitmap
platforms: linux/amd64
load: true
tags: rylween:smoke
- # Waits for the server to answer, as deploy.sh does (/api/status answers 401 without a
+ # Waits for the server to answer, as ./rylween serve does (/api/status answers 401 without a
# login), and checks the version in the server log's first line.
- name: Smoke-test the image
run: |
@@ -191,7 +191,7 @@ jobs:
uses: docker/build-push-action@v7
with:
context: .
- file: deploy/docker/Dockerfile.bitmap-production
+ file: deploy/docker/Dockerfile.bitmap
platforms: linux/amd64,linux/arm64
push: ${{ !inputs.dry-run }}
tags: |
@@ -217,16 +217,19 @@ jobs:
if: ${{ !inputs.dry-run }}
run: git push --atomic origin HEAD:refs/heads/main "refs/tags/v$RELEASE"
- # The checked-in compose.yaml builds the image from a checkout. The release's copy pulls
- # this release's image instead, and its compose.https.yaml pins that image too.
+ # The checked-in compose.yaml builds the images from a checkout. The release's copy pulls
+ # this release's bitmap image instead, without the ANSI game, which releases do not
+ # publish, and its compose.https.yaml pins the same image.
- name: Write the release's compose files
run: |
{
echo "# Adventurers of Rylween $RELEASE. \`docker compose up -d\` next to this file pulls"
- echo "# $IMAGE:$RELEASE; the notes below on --build and deploy.sh are for a source checkout."
+ echo "# $IMAGE:$RELEASE; the notes below on --build, the ANSI game, and ./rylween are for a"
+ echo "# source checkout."
echo "#"
yq --indent 4 \
- '.services.rylween.image = strenv(IMAGE) + ":" + strenv(RELEASE) | del(.services.rylween.build)' \
+ '.services.rylween.image = strenv(IMAGE) + ":" + strenv(RELEASE) | del(.services.rylween.build)
+ | del(.services.rylween-ansi) | del(.volumes.ansi-data)' \
deploy/compose.yaml
} > "$DIST/compose.yaml"
{
diff --git a/.gitignore b/.gitignore
index 0a585269..07e3ba90 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,6 +19,6 @@ node_modules/
# Local compose settings; may hold account passwords.
.env
-# Python tooling (support/audio)
+# Python tooling (game/audio-tools)
__pycache__/
.venv/
diff --git a/README.md b/README.md
index 6b8ad414..e10561e1 100644
--- a/README.md
+++ b/README.md
@@ -21,7 +21,7 @@ with [`deploy/README.md`](deploy/README.md), change the game with the
Each pair below is the same moment in the same game: the title screen, a
party at dawn in the wilderness just north of Thord, and the tavern in Thord.
The ANSI version keeps the look of the 1993 original and plays in a terminal
-with `./bin/run.sh`; the bitmap version is what `./deploy.sh` serves to browsers.
+with `./rylween`; the bitmap version is what `./rylween serve` serves to browsers.
@@ -81,32 +81,34 @@ brew install podman && podman machine init --now # Podman, and the Linux VM it
brew install --cask docker # or Docker Desktop; start it once from Applications
```
-### On Your Network: `./deploy.sh`
+### On This Machine Or Your Network: `./rylween serve`
```sh
-./deploy.sh
+./rylween serve # this machine only, http://127.0.0.1:8081/
+./rylween serve --lan # every machine on the local network
```
From a checkout, this builds the bitmap game's image, starts it with Docker
-Compose (Podman Compose when Docker is missing) on this machine's LAN address,
-port 8081, and waits until it answers. Then it prints the address to open on any
-machine on the network, with the commands for the sysop password, the server
-log, and stopping it. Saves and accounts survive rebuilds.
+Compose (Podman Compose when Docker is missing) on port 8081, and waits until it
+answers. Then it prints the address to open, with the commands for the sysop
+password, the server log, and stopping it. Saves and accounts survive rebuilds.
+It serves only this machine (`--local`) unless `--lan` shares it on this
+machine's LAN address; `./rylween stop` stops it.
### On The Internet, Over HTTPS
-On a machine with a public address and a domain name, `./deploy.sh --https`,
+On a machine with a public address and a domain name, `./rylween serve --https`,
or `deploy/compose.https.yaml` on its own, runs the released game behind Caddy,
which gets a Let's Encrypt certificate for the name.
-[`deploy/README.md`](deploy/README.md) covers all three ways: the settings,
-data and backups, and the images, and, step by step, everything an HTTPS server
-needs, from DNS and ports on.
+[`deploy/README.md`](deploy/README.md) covers all three ways: the `./rylween`
+command and its defaults, the settings, data and backups, and the images, and,
+step by step, everything an HTTPS server needs, from DNS and ports on.
-### In A Terminal: `./bin/run.sh`
+### In A Terminal: `./rylween`
```sh
-./bin/run.sh --build
+./rylween
```
This builds the game and plays the ANSI version in the current terminal. It
@@ -121,8 +123,9 @@ arrow keys or the keypad digits 8, 2, 4, and 6; press `?` in the wilderness for
the full list of commands, and `X` to quit. The save and logs go to
`~/.rylween/data`.
-[`bin/README.md`](bin/README.md) lists the other launchers and their options,
-such as starting with a seeded Strong party, and the local web servers.
+[`deploy/README.md`](deploy/README.md#playing-in-a-terminal) lists its options,
+such as starting with a seeded Strong party, and `./rylween help` lists every
+option of every command.
The game streams ANSI escape codes (color, cursor positioning) and uses
ambiguous-width Unicode characters in some art. How those characters are
@@ -149,7 +152,7 @@ of the next patch release, `X.Y.Z-SNAPSHOT`; see [Releasing](#releasing).
The current runnable Kotlin game is the `:runtime` project. Shared
DSL/compiler and compiled-bundle contracts live under `:core`, authored game
DSL and resources live under `:game`, the compiled-bundle emitter and its checks
-live under `:tools`, and ANSI terminal primitives live under `:terminal`.
+live under `:tools`, and ANSI terminal primitives live in `:runtime`.
The complete game DSL, the whole authored game from the world map and monsters
to every mission script, is
@@ -168,13 +171,11 @@ Module guides:
- [`:runtime`](runtimes/runtime/README.md) - shared game runtime and direct ANSI terminal.
- [`:runtime-web`](runtimes/runtime-web/README.md) - browser-served ANSI runtime.
- [`:runtime-bitmap-web`](runtimes/runtime-bitmap-web/README.md) - canvas bitmap runtime.
-- [`:web-common`](support/web-common/README.md) - shared web HTTP, WebSocket, auth, status.
-- [`:terminal`](support/terminal/README.md) - ANSI terminal primitives.
-- [`:tools`](support/tools/README.md) - emits, checks, and inspects the compiled bundle.
-- [`support/audio`](support/audio) - Python scripts that synthesize the sound effects, music, and ambient loops.
+- [`:web-common`](runtimes/web-common/README.md) - shared web HTTP, WebSocket, auth, status.
+- [`:tools`](tools/README.md) - emits, checks, and inspects the compiled bundle.
+- [`game/audio-tools`](game/audio-tools) - Python scripts that synthesize the sound effects, music, and ambient loops.
- [`build-logic`](build-logic/README.md) - Gradle conventions and custom tasks.
-- [`bin`](bin/README.md) - local developer/operator launcher scripts.
-- [`deploy`](deploy/README.md) - running the game as a server: compose files, Docker images, the deploy script, and HTTPS.
+- [`deploy`](deploy/README.md) - running the game: the `rylween` command, compose files, Docker images, and HTTPS.
The old interpreted Kotlin ANSI project and the historical C/JSON5 port are no
longer part of this repository. The original Amiga release is kept as described
@@ -200,7 +201,7 @@ CI (`.github/workflows/ci.yml`) runs the module checks on every push to `main`
and every pull request, leaving out the root dependency-update report:
```sh
-./gradlew --console=plain :core:check :game:check :tools:check :terminal:check :web-common:check :runtime:check :runtime-web:check :runtime-bitmap-web:check
+./gradlew --console=plain :core:check :game:check :tools:check :web-common:check :runtime:check :runtime-web:check :runtime-bitmap-web:check
```
ktlint findings fail `check`; `./gradlew ktlintFormat --console=plain` fixes
@@ -229,11 +230,12 @@ bitmap web game as the image `ghcr.io/lagergren/rylween:X.Y.Z` (also `:latest`)
for linux/amd64 and linux/arm64, and the terminal game as
`rylween-terminal-X.Y.Z.zip` (`./gradlew :runtime:terminalDistZip`), which runs
with `bin/rylween` on Java 25 or newer. It then moves `main` to
-`X.Y.(Z+1)-SNAPSHOT` and publishes the GitHub release with the zip and a
-`compose.yaml` that pulls the image. It refuses a version without `-SNAPSHOT`
-and a version that is tagged already. For a minor or major release, first set
-`rylween.version` to its snapshot, such as `X.(Y+1).0-SNAPSHOT`, in a pull
-request.
+`X.Y.(Z+1)-SNAPSHOT` and publishes the GitHub release with the zip, a
+`compose.yaml` that pulls the image, and a `compose.https.yaml` that runs it
+behind Caddy and HTTPS, both pinned to the release. It refuses a version
+without `-SNAPSHOT` and a version that is tagged already. For a minor or major
+release, first set `rylween.version` to its snapshot, such as
+`X.(Y+1).0-SNAPSHOT`, in a pull request.
`main` takes only pull requests, so the workflow pushes its commits with a
deploy key that the "Require PRs and CI on main" ruleset lets bypass that, kept
@@ -244,7 +246,7 @@ in the `RELEASE_DEPLOY_KEY` repository secret.
Generated files are Gradle build output, local Kotlin compiler caches, the
direct launcher's default saves and logs under `build/`, and the bitmap web
client's `node_modules` and downloaded Node.js under `runtimes/runtime-bitmap-web/`.
-The `bin/` scripts keep saves and logs in `~/.rylween/data`. From the repo root:
+`./rylween` keeps saves and logs in `~/.rylween/data`. From the repo root:
```sh
./gradlew clean --console=plain
diff --git a/bin/README.md b/bin/README.md
deleted file mode 100644
index 70c25fd7..00000000
--- a/bin/README.md
+++ /dev/null
@@ -1,100 +0,0 @@
-# Launcher Scripts
-
-`bin/` contains local developer and operator entrypoints for running Rylween
-from this checkout.
-
-- `run.sh` launches the direct ANSI terminal runtime, building the bundle and
- install first with `--build` or when they are missing.
-- `run-server.sh` runs the browser-served ANSI web runtime in Docker on
- `127.0.0.1:8080`; `--build` rebuilds the `deploy/docker/Dockerfile` image
- first.
-- `run-bitmap-server.sh` launches the bitmap web runtime locally on
- `127.0.0.1:8081`, building the install first with `--build` or when it is
- missing.
-- `backup-web-data.sh` archives saves and web auth records from the data
- directory; `--include-logs` adds the logs.
-
-All three launchers take `--name Strong` or `--name StrongEndgame` to seed and
-load a named save, and keep their data under `~/.rylween/data`
-(`RYLWEEN_DATA_DIR`, or `RYLWEEN_HOST_DATA_DIR` for `run-server.sh`).
-
-These scripts are intentionally not under `deploy/`: they are normal checkout
-commands, useful for development, smoke testing, local play, and simple
-operations. Production packaging lives under `deploy/docker/`. Container and
-LAN rollout lives in `deploy/`: `compose.yaml` and `deploy-rylween.sh`, which
-the root `./deploy.sh` links to.
-
-Run them from the repository root.
-
-## Terminal Game
-
-```sh
-./bin/run.sh --build --seed 1
-./bin/run.sh --build --name Strong
-./bin/run.sh --build --name StrongEndgame
-```
-
-`run.sh` builds `build/compiled/rylween-bundle.json` and
-`:runtime:installRuntime` when needed, injects the bundle path, and runs outside
-Gradle so Gradle progress output and key echo do not share the game screen. The
-installed launcher can also be run directly:
-
-```sh
-./gradlew :tools:emitExternalCompiledBundle :runtime:installRuntime --console=plain
-runtimes/runtime/build/install/rylween/bin/rylween --bundle build/compiled/rylween-bundle.json --user local --state fresh-replay --seed 1
-```
-
-`run.sh` stores the shared save at `~/.rylween/data/saves/world.rsave` and logs
-to `~/.rylween/data/logs/runtime/latest.log` unless `RYLWEEN_DATA_DIR`,
-`RYLWEEN_SAVE_FILE`, or `RYLWEEN_LOG_FILE` override those paths.
-
-The terminal game's release download, `rylween-terminal-X.Y.Z.zip` from
-`./gradlew :runtime:terminalDistZip`, ships this script as `bin/rylween`. There
-it runs the launcher (`bin/rylween-runtime`) and the bundle beside it, with the
-same options and data paths, and refuses `--build`.
-
-It shows the title flow by default. Use `--name Strong` to load the seeded
-Strong party outside Thord, or `--name StrongEndgame` to load a Strong party two
-steps north of Castle Ydarg with the five required power artifacts. Use
-`--no-title` only when you intentionally want to boot a state or feed a direct
-script. Use `--log ` to keep a named capture instead of replacing
-`latest.log`. For manual forensics, `--debug-log` flashes the latest log line
-below the game frame, and `--debug-secrets` enables hidden wilderness keys: `[`
-forces a cave discovery, `]` forces a random encounter, and `M` shows the whole
-world map.
-
-```sh
-./bin/run.sh --screen title
-./bin/run.sh --no-title --script 22SX --save build/saves/runtime.rsave
-./bin/run.sh --load build/saves/runtime.rsave
-./bin/run.sh --name Strong --debug-log --debug-secrets
-```
-
-## Web Servers
-
-```sh
-./bin/run-server.sh --build
-./bin/run-server.sh --build --name Strong
-./bin/run-server.sh --account Strong --email strong@example.test --password 'change-this-password'
-
-./bin/run-bitmap-server.sh --build
-./bin/run-bitmap-server.sh --build --name StrongEndgame
-./bin/run-bitmap-server.sh --account Strong --email strong@example.test --password 'change-this-password'
-```
-
-The ANSI server publishes on http://127.0.0.1:8080/ and the bitmap server on
-http://127.0.0.1:8081/. The named forms seed `~/.rylween/data/saves/world.rsave`
-before starting and use the local development auth bypass. The account form
-creates or verifies a persisted web account before the server starts.
-
-## Backup
-
-```sh
-./bin/backup-web-data.sh --data ~/.rylween/data --output rylween-backup.tar.gz
-```
-
-The data directory is split by ownership: `saves/world.rsave` is game state,
-`auth/users` is account state, and `logs` is operational history. The exact file
-layout and field meanings are documented in
-[`support/web-common/README.md`](../support/web-common/README.md) and
-[`runtimes/runtime/README.md`](../runtimes/runtime/README.md).
diff --git a/bin/backup-web-data.sh b/bin/backup-web-data.sh
deleted file mode 100755
index ba211261..00000000
--- a/bin/backup-web-data.sh
+++ /dev/null
@@ -1,88 +0,0 @@
-#!/usr/bin/env bash
-set -euo pipefail
-
-DATA_DIR="${RYLWEEN_DATA_DIR:-$HOME/.rylween/data}"
-OUTPUT=""
-INCLUDE_LOGS=false
-
-usage() {
- cat <<'EOF'
-Usage: ./bin/backup-web-data.sh [--data DIR] [--output FILE] [--include-logs]
-
-Creates one compressed archive containing the shared world save and persisted
-web auth users. Logs are excluded by default because they can be large and may
-contain operational/user activity.
-
-Environment:
- RYLWEEN_DATA_DIR Data directory to back up. Default: ~/.rylween/data
-EOF
-}
-
-require_next_arg() {
- local option="$1"
- if [[ $# -lt 2 ]]; then
- echo "$option requires a value" >&2
- exit 2
- fi
-}
-
-while [[ $# -gt 0 ]]; do
- arg="$1"
- shift
- case "$arg" in
- --data)
- require_next_arg "$arg" "$@"
- DATA_DIR="$1"
- shift
- ;;
- --data=*)
- DATA_DIR="${arg#--data=}"
- ;;
- --output)
- require_next_arg "$arg" "$@"
- OUTPUT="$1"
- shift
- ;;
- --output=*)
- OUTPUT="${arg#--output=}"
- ;;
- --include-logs)
- INCLUDE_LOGS=true
- ;;
- --help|-h)
- usage
- exit 0
- ;;
- *)
- echo "Unknown option: $arg" >&2
- usage >&2
- exit 2
- ;;
- esac
-done
-
-if [[ ! -d "$DATA_DIR" ]]; then
- echo "Data directory does not exist: $DATA_DIR" >&2
- exit 1
-fi
-
-if [[ -z "$OUTPUT" ]]; then
- timestamp="$(date -u +%Y%m%dT%H%M%SZ)"
- OUTPUT="rylween-web-data-$timestamp.tar.gz"
-fi
-
-entries=()
-[[ -e "$DATA_DIR/saves" ]] && entries+=("saves")
-[[ -e "$DATA_DIR/auth/users" ]] && entries+=("auth/users")
-if [[ "$INCLUDE_LOGS" == true && -e "$DATA_DIR/logs" ]]; then
- entries+=("logs")
-fi
-
-if [[ ${#entries[@]} -eq 0 ]]; then
- echo "Nothing to back up under $DATA_DIR." >&2
- exit 1
-fi
-
-mkdir -p "$(dirname "$OUTPUT")"
-tar -C "$DATA_DIR" -czf "$OUTPUT" "${entries[@]}"
-printf '[rylween-backup] wrote %s from %s\n' "$OUTPUT" "$DATA_DIR"
diff --git a/bin/run-bitmap-server.sh b/bin/run-bitmap-server.sh
deleted file mode 100755
index e7ce8849..00000000
--- a/bin/run-bitmap-server.sh
+++ /dev/null
@@ -1,236 +0,0 @@
-#!/usr/bin/env bash
-set -euo pipefail
-
-ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
-INSTALL_HOME="$ROOT_DIR/runtimes/runtime-bitmap-web/build/install/rylween-bitmap-web"
-LAUNCHER="$INSTALL_HOME/bin/rylween-bitmap-web"
-
-DATA_DIR="${RYLWEEN_DATA_DIR:-$HOME/.rylween/data}"
-HOST="${RYLWEEN_BITMAP_HOST:-${RYLWEEN_HOST:-127.0.0.1}}"
-PORT="${RYLWEEN_BITMAP_PORT:-${RYLWEEN_PORT:-8081}}"
-STATE="${RYLWEEN_BITMAP_STATE:-${RYLWEEN_STATE:-fresh-replay}}"
-MAP_TILES="${RYLWEEN_BITMAP_MAP_TILES:-6}"
-TILE_SIZE="${RYLWEEN_BITMAP_TILE_SIZE:-68}"
-RUN_NAME="${RYLWEEN_BITMAP_NAME:-${RYLWEEN_NAME:-}}"
-RUN_USER="${RYLWEEN_BITMAP_USER:-${RYLWEEN_USER:-}}"
-AUTH_ACCOUNT="${RYLWEEN_AUTH_ACCOUNT:-}"
-AUTH_EMAIL="${RYLWEEN_AUTH_EMAIL:-}"
-AUTH_PASSWORD="${RYLWEEN_AUTH_PASSWORD:-}"
-AUTH_SECURE_COOKIES="${RYLWEEN_AUTH_SECURE_COOKIES:-}"
-LOAD_FILE="${RYLWEEN_BITMAP_LOAD_FILE:-${RYLWEEN_LOAD_FILE:-}}"
-SAVE_FILE="${RYLWEEN_BITMAP_SAVE_FILE:-${RYLWEEN_SAVE_FILE:-}}"
-DEFAULT_SAVE_FILE="$DATA_DIR/saves/world.rsave"
-BUILD=false
-args=()
-
-usage() {
- cat <<'EOF'
-Usage: ./bin/run-bitmap-server.sh [--build] [--name NAME] [--host HOST] [--port PORT] [--state SLUG] [--debug-secrets] [--map-tiles N] [--tile-size PX]
- ./bin/run-bitmap-server.sh --account NAME --password PASSWORD [--email EMAIL]
-
-Environment:
- RYLWEEN_DATA_DIR Authenticated save/log/user data directory. Default: ~/.rylween/data
- RYLWEEN_BITMAP_NAME Optional named local save to seed/load. Examples: Strong, StrongEndgame
- RYLWEEN_BITMAP_USER Save/load user id when not using --name.
- RYLWEEN_BITMAP_HOST Bind host. Default: RYLWEEN_HOST or 127.0.0.1
- RYLWEEN_BITMAP_PORT Bind port. Default: RYLWEEN_PORT or 8081
- RYLWEEN_BITMAP_STATE Initial compiled state slug. Default: fresh-replay
- RYLWEEN_BITMAP_LOAD_FILE Optional shared world save to load.
- RYLWEEN_BITMAP_SAVE_FILE Optional shared world save path.
- RYLWEEN_BITMAP_MAP_TILES Wilderness viewport edge length. Default: 6
- RYLWEEN_BITMAP_TILE_SIZE Wilderness tile size in px. Default: 68
- RYLWEEN_BITMAP_DEBUG_SECRETS Set true to enable hidden manual-test wilderness commands.
- RYLWEEN_BITMAP_BUNDLE Optional external bundle path. Embedded game is used when omitted.
- RYLWEEN_AUTH_ACCOUNT Optional account to create/verify before startup.
- RYLWEEN_AUTH_EMAIL Optional email for RYLWEEN_AUTH_ACCOUNT.
- RYLWEEN_AUTH_PASSWORD Required when RYLWEEN_AUTH_ACCOUNT is set.
- RYLWEEN_AUTH_SECURE_COOKIES Set true when served through HTTPS.
-EOF
-}
-
-require_next_arg() {
- local option="$1"
- if [[ $# -lt 2 ]]; then
- echo "$option requires a value" >&2
- exit 2
- fi
-}
-
-while [[ $# -gt 0 ]]; do
- arg="$1"
- shift
- case "$arg" in
- --build)
- BUILD=true
- ;;
- --name)
- require_next_arg "$arg" "$@"
- RUN_NAME="$1"
- shift
- ;;
- --name=*)
- RUN_NAME="${arg#--name=}"
- ;;
- --user)
- require_next_arg "$arg" "$@"
- RUN_USER="$1"
- shift
- ;;
- --user=*)
- RUN_USER="${arg#--user=}"
- ;;
- --account)
- require_next_arg "$arg" "$@"
- AUTH_ACCOUNT="$1"
- shift
- ;;
- --account=*)
- AUTH_ACCOUNT="${arg#--account=}"
- ;;
- --email)
- require_next_arg "$arg" "$@"
- AUTH_EMAIL="$1"
- shift
- ;;
- --email=*)
- AUTH_EMAIL="${arg#--email=}"
- ;;
- --password)
- require_next_arg "$arg" "$@"
- AUTH_PASSWORD="$1"
- shift
- ;;
- --password=*)
- AUTH_PASSWORD="${arg#--password=}"
- ;;
- --secure-cookies)
- AUTH_SECURE_COOKIES=true
- ;;
- --load)
- require_next_arg "$arg" "$@"
- LOAD_FILE="$1"
- shift
- ;;
- --load=*)
- LOAD_FILE="${arg#--load=}"
- ;;
- --save)
- require_next_arg "$arg" "$@"
- SAVE_FILE="$1"
- shift
- ;;
- --save=*)
- SAVE_FILE="${arg#--save=}"
- ;;
- --title|--no-title)
- args+=("$arg")
- ;;
- --debug-secrets)
- args+=("$arg")
- ;;
- --host)
- require_next_arg "$arg" "$@"
- HOST="$1"
- shift
- ;;
- --host=*)
- HOST="${arg#--host=}"
- ;;
- --port)
- require_next_arg "$arg" "$@"
- PORT="$1"
- shift
- ;;
- --port=*)
- PORT="${arg#--port=}"
- ;;
- --state)
- require_next_arg "$arg" "$@"
- STATE="$1"
- shift
- ;;
- --state=*)
- STATE="${arg#--state=}"
- ;;
- --map-tiles)
- require_next_arg "$arg" "$@"
- MAP_TILES="$1"
- shift
- ;;
- --map-tiles=*)
- MAP_TILES="${arg#--map-tiles=}"
- ;;
- --tile-size)
- require_next_arg "$arg" "$@"
- TILE_SIZE="$1"
- shift
- ;;
- --tile-size=*)
- TILE_SIZE="${arg#--tile-size=}"
- ;;
- --help|-h)
- usage
- exit 0
- ;;
- *)
- args+=("$arg")
- ;;
- esac
-done
-
-if [[ "$BUILD" == true || ! -x "$LAUNCHER" ]]; then
- (cd "$ROOT_DIR" && ./gradlew :runtime-bitmap-web:installRuntimeBitmapWeb --console=plain)
-fi
-
-if [[ -n "$RUN_NAME" ]]; then
- if [[ -n "$RUN_USER" ]]; then
- echo "Use either --name or --user, not both." >&2
- exit 2
- fi
- if [[ -z "$SAVE_FILE" ]]; then
- SAVE_FILE="$DEFAULT_SAVE_FILE"
- fi
- mkdir -p "$DATA_DIR/saves" "$DATA_DIR/logs/runtime-bitmap-web"
- seed_console="$DATA_DIR/logs/runtime-bitmap-web/seed-${RUN_NAME}.console.log"
- RYLWEEN_DATA_DIR="$DATA_DIR" \
- RYLWEEN_SAVE_FILE="$SAVE_FILE" \
- RYLWEEN_LOG_FILE="$DATA_DIR/logs/runtime-bitmap-web/seed-${RUN_NAME}.log" \
- "$ROOT_DIR/bin/run.sh" --build --name "$RUN_NAME" --script X >"$seed_console" 2>&1
- RUN_USER="$RUN_NAME"
- LOAD_FILE="$SAVE_FILE"
-fi
-
-if [[ -n "$RUN_USER" ]]; then
- args=("--user" "$RUN_USER" "${args[@]}")
-fi
-
-if [[ -n "$AUTH_ACCOUNT" || -n "$AUTH_EMAIL" || -n "$AUTH_PASSWORD" ]]; then
- if [[ -z "$AUTH_ACCOUNT" || -z "$AUTH_PASSWORD" ]]; then
- echo "--account and --password are both required when bootstrapping an account." >&2
- exit 2
- fi
- args=("--account" "$AUTH_ACCOUNT" "--password" "$AUTH_PASSWORD" "${args[@]}")
- if [[ -n "$AUTH_EMAIL" ]]; then
- args=("--email" "$AUTH_EMAIL" "${args[@]}")
- fi
-fi
-
-if [[ "$AUTH_SECURE_COOKIES" == "true" ]]; then
- args=("--secure-cookies" "${args[@]}")
-fi
-
-if [[ -n "$LOAD_FILE" ]]; then
- args=("--load" "$LOAD_FILE" "${args[@]}")
-fi
-
-if [[ -n "$SAVE_FILE" ]]; then
- args=("--save" "$SAVE_FILE" "${args[@]}")
-fi
-
-bundle="${RYLWEEN_BITMAP_BUNDLE:-}"
-if [[ -n "$bundle" ]]; then
- args=("--bundle" "$bundle" "${args[@]}")
-fi
-
-echo "[rylween-bitmap] URL: http://$HOST:$PORT/"
-exec "$LAUNCHER" --host "$HOST" --port "$PORT" --data "$DATA_DIR" --state "$STATE" --map-tiles "$MAP_TILES" --tile-size "$TILE_SIZE" "${args[@]}"
diff --git a/bin/run-server.sh b/bin/run-server.sh
deleted file mode 100755
index 46254d5a..00000000
--- a/bin/run-server.sh
+++ /dev/null
@@ -1,223 +0,0 @@
-#!/usr/bin/env bash
-set -euo pipefail
-
-ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
-
-IMAGE="${RYLWEEN_IMAGE:-rylween:latest}"
-CONTAINER_NAME="${RYLWEEN_CONTAINER_NAME:-rylween-web}"
-HOST_DATA_DIR="${RYLWEEN_HOST_DATA_DIR:-$HOME/.rylween/data}"
-CONTAINER_DATA_DIR="${RYLWEEN_CONTAINER_DATA_DIR:-/data}"
-CONTAINER_HOST="${RYLWEEN_CONTAINER_HOST:-0.0.0.0}"
-CONTAINER_PORT="${RYLWEEN_CONTAINER_PORT:-${RYLWEEN_PORT:-8080}}"
-HOST_PORT="${RYLWEEN_HOST_PORT:-$CONTAINER_PORT}"
-PUBLISH_HOST="${RYLWEEN_PUBLISH_HOST:-127.0.0.1}"
-BUILD_IMAGE="${RYLWEEN_BUILD:-false}"
-RUN_NAME="${RYLWEEN_NAME:-}"
-AUTH_ACCOUNT="${RYLWEEN_AUTH_ACCOUNT:-}"
-AUTH_EMAIL="${RYLWEEN_AUTH_EMAIL:-}"
-AUTH_PASSWORD="${RYLWEEN_AUTH_PASSWORD:-}"
-AUTH_SECURE_COOKIES="${RYLWEEN_AUTH_SECURE_COOKIES:-}"
-CONTAINER_SAVE_FILE="${RYLWEEN_SAVE_FILE:-$CONTAINER_DATA_DIR/saves/world.rsave}"
-HOST_SAVE_FILE=""
-
-log() {
- printf '[rylween-server] %s\n' "$*"
-}
-
-usage() {
- cat <<'EOF'
-Usage: ./bin/run-server.sh [--build] [--name NAME]
- ./bin/run-server.sh --account NAME --password PASSWORD [--email EMAIL]
-
-Environment:
- RYLWEEN_IMAGE Docker image tag. Default: rylween:latest
- RYLWEEN_BUILD Build image before running when set to true.
- RYLWEEN_NAME Optional named local save to seed before running. Examples: Strong, StrongEndgame
- RYLWEEN_CONTAINER_NAME Docker container name. Default: rylween-web
- RYLWEEN_HOST_DATA_DIR Host data directory. Default: ~/.rylween/data
- RYLWEEN_HOST_PORT Host port to publish. Default: container port
- RYLWEEN_PUBLISH_HOST Host interface to publish. Default: 127.0.0.1
- RYLWEEN_CONTAINER_PORT Container app port. Default: RYLWEEN_PORT or 8080
- RYLWEEN_STATE Optional initial runtime state slug.
- RYLWEEN_SAVE_FILE Optional shared world save path inside the container. Default: /data/saves/world.rsave
- RYLWEEN_LOAD_FILE Optional initial world save path used only when RYLWEEN_SAVE_FILE does not exist.
- RYLWEEN_AUTH_ACCOUNT Optional account to create/verify before startup.
- RYLWEEN_AUTH_EMAIL Optional email for RYLWEEN_AUTH_ACCOUNT.
- RYLWEEN_AUTH_PASSWORD Required when RYLWEEN_AUTH_ACCOUNT is set.
- RYLWEEN_AUTH_SECURE_COOKIES Set true when served through HTTPS.
- RYLWEEN_SEED Optional runtime RNG seed.
-EOF
-}
-
-while [[ $# -gt 0 ]]; do
- arg="$1"
- shift
- case "$arg" in
- --build)
- BUILD_IMAGE=true
- ;;
- --name)
- if [[ $# -eq 0 ]]; then
- echo "--name requires a value" >&2
- exit 2
- fi
- RUN_NAME="$1"
- shift
- ;;
- --name=*)
- RUN_NAME="${arg#--name=}"
- ;;
- --account)
- if [[ $# -eq 0 ]]; then
- echo "--account requires a value" >&2
- exit 2
- fi
- AUTH_ACCOUNT="$1"
- shift
- ;;
- --account=*)
- AUTH_ACCOUNT="${arg#--account=}"
- ;;
- --email)
- if [[ $# -eq 0 ]]; then
- echo "--email requires a value" >&2
- exit 2
- fi
- AUTH_EMAIL="$1"
- shift
- ;;
- --email=*)
- AUTH_EMAIL="${arg#--email=}"
- ;;
- --password)
- if [[ $# -eq 0 ]]; then
- echo "--password requires a value" >&2
- exit 2
- fi
- AUTH_PASSWORD="$1"
- shift
- ;;
- --password=*)
- AUTH_PASSWORD="${arg#--password=}"
- ;;
- --secure-cookies)
- AUTH_SECURE_COOKIES=true
- ;;
- --help|-h)
- usage
- exit 0
- ;;
- *)
- echo "Unknown option: $arg" >&2
- usage >&2
- exit 2
- ;;
- esac
-done
-
-case "$CONTAINER_SAVE_FILE" in
- "$CONTAINER_DATA_DIR"/*)
- HOST_SAVE_FILE="$HOST_DATA_DIR/${CONTAINER_SAVE_FILE#"$CONTAINER_DATA_DIR/"}"
- ;;
-esac
-
-mkdir -p "$HOST_DATA_DIR/saves" "$HOST_DATA_DIR/logs"
-
-if [[ "$BUILD_IMAGE" == true ]]; then
- log "building image: $IMAGE"
- log "build context: $ROOT_DIR"
- docker build -f "$ROOT_DIR/deploy/docker/Dockerfile" -t "$IMAGE" "$ROOT_DIR"
-fi
-
-if [[ -n "$RUN_NAME" ]]; then
- if [[ -z "$HOST_SAVE_FILE" ]]; then
- echo "Cannot seed --name $RUN_NAME because RYLWEEN_SAVE_FILE is outside $CONTAINER_DATA_DIR." >&2
- exit 2
- fi
- seed_console="$HOST_DATA_DIR/logs/runtime/seed-${RUN_NAME}.console.log"
- mkdir -p "$(dirname "$seed_console")"
- log "seeding named save: $RUN_NAME"
- log "seed host save: $HOST_SAVE_FILE"
- log "seed console log: $seed_console"
- RYLWEEN_DATA_DIR="$HOST_DATA_DIR" \
- RYLWEEN_SAVE_FILE="$HOST_SAVE_FILE" \
- RYLWEEN_LOG_FILE="$HOST_DATA_DIR/logs/runtime/latest.log" \
- "$ROOT_DIR/bin/run.sh" --build --name "$RUN_NAME" --script X >"$seed_console" 2>&1
-fi
-
-env_args=(
- -e "RYLWEEN_DATA_DIR=$CONTAINER_DATA_DIR"
- -e "RYLWEEN_HOST=$CONTAINER_HOST"
- -e "RYLWEEN_PORT=$CONTAINER_PORT"
-)
-
-forward_env() {
- local name="$1"
- local value="${!name:-}"
- if [[ -n "$value" ]]; then
- env_args+=(-e "$name=$value")
- fi
-}
-
-forward_env RYLWEEN_STATE
-forward_env RYLWEEN_SAVE_FILE
-forward_env RYLWEEN_LOAD_FILE
-forward_env RYLWEEN_SEED
-forward_env RYLWEEN_BUNDLE
-forward_env RYLWEEN_AUTH_DEV_USER
-forward_env RYLWEEN_ADMIN_ACCOUNT
-forward_env RYLWEEN_ADMIN_PASSWORD
-forward_env RYLWEEN_VICTIM_ACCOUNT
-
-if [[ -n "$AUTH_ACCOUNT" || -n "$AUTH_EMAIL" || -n "$AUTH_PASSWORD" ]]; then
- if [[ -z "$AUTH_ACCOUNT" || -z "$AUTH_PASSWORD" ]]; then
- echo "--account and --password are both required when bootstrapping an account." >&2
- exit 2
- fi
- env_args+=(-e "RYLWEEN_AUTH_ACCOUNT=$AUTH_ACCOUNT")
- env_args+=(-e "RYLWEEN_AUTH_PASSWORD=$AUTH_PASSWORD")
- if [[ -n "$AUTH_EMAIL" ]]; then
- env_args+=(-e "RYLWEEN_AUTH_EMAIL=$AUTH_EMAIL")
- fi
-fi
-
-if [[ "$AUTH_SECURE_COOKIES" == "true" ]]; then
- env_args+=(-e "RYLWEEN_AUTH_SECURE_COOKIES=true")
-fi
-
-if [[ -n "$RUN_NAME" && -z "${RYLWEEN_AUTH_DEV_USER:-}" ]]; then
- env_args+=(-e "RYLWEEN_AUTH_DEV_USER=$RUN_NAME")
-fi
-
-log "image: $IMAGE"
-log "container: $CONTAINER_NAME"
-log "build before run: $BUILD_IMAGE"
-log "host data dir: $HOST_DATA_DIR"
-log "container data dir: $CONTAINER_DATA_DIR"
-log "volume: $HOST_DATA_DIR:$CONTAINER_DATA_DIR"
-log "publish: $PUBLISH_HOST:$HOST_PORT -> $CONTAINER_PORT"
-log "container bind host: $CONTAINER_HOST"
-log "container data subdirs: $CONTAINER_DATA_DIR/saves and $CONTAINER_DATA_DIR/logs"
-log "default shared world save: $CONTAINER_SAVE_FILE"
-if [[ -n "$HOST_SAVE_FILE" ]]; then
- log "host shared world save: $HOST_SAVE_FILE"
-fi
-if [[ -n "$RUN_NAME" ]]; then
- log "seeded name: $RUN_NAME"
- log "dev auth bypass user: $RUN_NAME"
-fi
-for name in RYLWEEN_STATE RYLWEEN_SAVE_FILE RYLWEEN_LOAD_FILE RYLWEEN_SEED RYLWEEN_BUNDLE RYLWEEN_AUTH_DEV_USER RYLWEEN_AUTH_ACCOUNT RYLWEEN_AUTH_EMAIL RYLWEEN_AUTH_SECURE_COOKIES RYLWEEN_ADMIN_ACCOUNT RYLWEEN_VICTIM_ACCOUNT; do
- value="${!name:-}"
- if [[ -n "$value" ]]; then
- log "forward env: $name=$value"
- fi
-done
-log "starting docker container"
-
-exec docker run \
- --rm \
- --name "$CONTAINER_NAME" \
- -p "$PUBLISH_HOST:$HOST_PORT:$CONTAINER_PORT" \
- -v "$HOST_DATA_DIR:$CONTAINER_DATA_DIR" \
- "${env_args[@]}" \
- "$IMAGE"
diff --git a/bin/run.sh b/bin/run.sh
deleted file mode 100755
index 623fb71b..00000000
--- a/bin/run.sh
+++ /dev/null
@@ -1,254 +0,0 @@
-#!/usr/bin/env bash
-set -euo pipefail
-
-ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
-# In the terminal game's release download (./gradlew :runtime:terminalDistZip)
-# this script is bin/rylween, next to the runtime's own start script and the
-# compiled bundle. In a checkout it builds both when needed.
-if [[ -f "$ROOT_DIR/rylween-bundle.json" ]]; then
- distribution=true
- LAUNCHER="$ROOT_DIR/bin/rylween-runtime"
- BUNDLE="$ROOT_DIR/rylween-bundle.json"
-else
- distribution=false
- INSTALL_HOME="$ROOT_DIR/runtimes/runtime/build/install/rylween"
- LAUNCHER="$INSTALL_HOME/bin/rylween"
- BUNDLE="$ROOT_DIR/build/compiled/rylween-bundle.json"
-fi
-DATA_DIR="${RYLWEEN_DATA_DIR:-$HOME/.rylween/data}"
-DEFAULT_SAVE_FILE="${RYLWEEN_SAVE_FILE:-$DATA_DIR/saves/world.rsave}"
-DEFAULT_LOG_FILE="${RYLWEEN_LOG_FILE:-$DATA_DIR/logs/runtime/latest.log}"
-DEFAULT_USER="${RYLWEEN_USER:-local}"
-run_name="${RYLWEEN_NAME:-}"
-
-require_next_arg() {
- local option="$1"
- if [[ $# -lt 2 ]]; then
- echo "$option requires a value" >&2
- exit 2
- fi
-}
-
-build=false
-title_seen=false
-bundle_seen=false
-user_seen=false
-load_seen=false
-save_seen=false
-log_seen=false
-args=()
-while [[ $# -gt 0 ]]; do
- arg="$1"
- shift
- case "$arg" in
- --build)
- build=true
- ;;
- --title|--no-title)
- title_seen=true
- args+=("$arg")
- ;;
- --bundle)
- require_next_arg "$arg" "$@"
- bundle_seen=true
- args+=("$arg" "$1")
- shift
- ;;
- --bundle=*)
- bundle_seen=true
- args+=("$arg")
- ;;
- --user)
- require_next_arg "$arg" "$@"
- user_seen=true
- args+=("$arg" "$1")
- shift
- ;;
- --user=*)
- user_seen=true
- args+=("$arg")
- ;;
- --name)
- require_next_arg "$arg" "$@"
- run_name="$1"
- shift
- ;;
- --name=*)
- run_name="${arg#--name=}"
- ;;
- --load)
- require_next_arg "$arg" "$@"
- load_seen=true
- args+=("$arg" "$1")
- shift
- ;;
- --load=*)
- load_seen=true
- args+=("$arg")
- ;;
- --save)
- require_next_arg "$arg" "$@"
- save_seen=true
- args+=("$arg" "$1")
- shift
- ;;
- --save=*)
- save_seen=true
- args+=("$arg")
- ;;
- --log)
- require_next_arg "$arg" "$@"
- log_seen=true
- args+=("$arg" "$1")
- shift
- ;;
- --log=*)
- log_seen=true
- args+=("$arg")
- ;;
- --state|--screen|--script|--seed)
- require_next_arg "$arg" "$@"
- args+=("$arg" "$1")
- shift
- ;;
- --state=*|--screen=*|--script=*|--seed=*)
- args+=("$arg")
- ;;
- --*)
- args+=("$arg")
- ;;
- *)
- echo "Unknown argument: $arg" >&2
- echo "Use --name Strong or --name StrongEndgame to load a named save from $DEFAULT_SAVE_FILE." >&2
- exit 2
- ;;
- esac
-done
-
-mkdir -p "$(dirname "$DEFAULT_SAVE_FILE")" "$(dirname "$DEFAULT_LOG_FILE")"
-
-if [[ "$build" == true || ! -x "$LAUNCHER" || ! -f "$BUNDLE" ]]; then
- if [[ "$distribution" == true ]]; then
- echo "--build needs a source checkout; this download comes built." >&2
- exit 2
- fi
- (cd "$ROOT_DIR" && ./gradlew :tools:emitExternalCompiledBundle :runtime:installRuntime --console=plain)
-fi
-
-if [[ "$bundle_seen" == false ]]; then
- args=("--bundle" "$BUNDLE" "${args[@]}")
-fi
-
-if [[ "$save_seen" == false ]]; then
- args=("--save" "$DEFAULT_SAVE_FILE" "${args[@]}")
-fi
-
-if [[ "$log_seen" == false ]]; then
- args=("--log" "$DEFAULT_LOG_FILE" "${args[@]}")
-fi
-
-if [[ -n "$run_name" ]]; then
- if [[ "$user_seen" == true ]]; then
- echo "Use either --name or --user, not both." >&2
- exit 2
- fi
- args=("--user" "$run_name" "${args[@]}")
- if [[ "$load_seen" == false ]]; then
- args=("--load" "$DEFAULT_SAVE_FILE" "${args[@]}")
- fi
- if [[ "$title_seen" == false ]]; then
- args=("--no-title" "${args[@]}")
- title_seen=true
- fi
-else
- if [[ "$user_seen" == false ]]; then
- args=("--user" "$DEFAULT_USER" "${args[@]}")
- fi
-fi
-
-named_state_for_run_name() {
- case "$1" in
- Strong|strong)
- echo "strong-replay"
- ;;
- StrongEndgame|strong-endgame|strong_endgame|Endgame|endgame|Ydarg|ydarg)
- echo "strong-endgame-replay"
- ;;
- *)
- return 1
- ;;
- esac
-}
-
-named_party_for_run_name() {
- case "$1" in
- Strong|strong)
- echo "Strong"
- ;;
- StrongEndgame|strong-endgame|strong_endgame|Endgame|endgame|Ydarg|ydarg)
- echo "Strong Endgame"
- ;;
- *)
- return 1
- ;;
- esac
-}
-
-normalized_run_user() {
- printf '%s' "$1" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9_-]/_/g'
-}
-
-ensure_named_save() {
- if [[ -z "$run_name" ]]; then
- return
- fi
- seed_state="$(named_state_for_run_name "$run_name")" || return
- expected_party="$(named_party_for_run_name "$run_name")" || return
- expected_user="$(normalized_run_user "$run_name")"
- bundle_hash="$(sed -n 's/.*"bundleContentHash": "\([^"]*\)".*/\1/p' "$BUNDLE" | head -n 1)"
- save_hash=""
- if [[ -f "$DEFAULT_SAVE_FILE" ]]; then
- save_hash="$(sed -n 's/^bundleHash=//p' "$DEFAULT_SAVE_FILE" | head -n 1)"
- fi
- if [[ -f "$DEFAULT_SAVE_FILE" ]] && grep -q "^user\\.[0-9][0-9]*\\.id=$expected_user$" "$DEFAULT_SAVE_FILE"; then
- if [[ -n "$bundle_hash" && "$save_hash" == "$bundle_hash" ]] &&
- grep -q "^user\\.[0-9][0-9]*\\.party\\.name=$expected_party$" "$DEFAULT_SAVE_FILE"; then
- return
- fi
- fi
- "$LAUNCHER" \
- --bundle "$BUNDLE" \
- --user "$run_name" \
- --state "$seed_state" \
- --save "$DEFAULT_SAVE_FILE" \
- --script SX \
- --no-title \
- --log "$DATA_DIR/logs/runtime/seed-${run_name}.log" \
- >/dev/null
-}
-
-ensure_named_save
-
-if [[ "$title_seen" == false ]]; then
- args=("--title" "${args[@]}")
-fi
-
-# A release download is never rebuilt, so it runs in place.
-if [[ "$distribution" == true ]]; then
- exec "$LAUNCHER" "${args[@]}"
-fi
-
-RUN_PARENT="$(mktemp -d "${TMPDIR:-/tmp}/rylween-run.XXXXXX")"
-cleanup() {
- rm -rf "$RUN_PARENT"
-}
-trap cleanup EXIT
-
-# Run from a private copy so Gradle rebuilds/tests cannot rewrite jars under
-# an active game process and trigger lazy classpath ZipFile failures.
-cp -R "$INSTALL_HOME" "$RUN_PARENT/"
-RUN_LAUNCHER="$RUN_PARENT/rylween/bin/rylween"
-
-status=0
-"$RUN_LAUNCHER" "${args[@]}" || status=$?
-exit "$status"
diff --git a/build.gradle.kts b/build.gradle.kts
index 3d3468c3..002e6c7c 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -29,7 +29,6 @@ tasks.check {
dependsOn(":core:check")
dependsOn(":game:check")
dependsOn(":tools:check")
- dependsOn(":terminal:check")
dependsOn(":runtime:check")
dependsOn(":runtime-web:check")
dependsOn(":runtime-bitmap-web:check")
diff --git a/deploy.sh b/deploy.sh
deleted file mode 120000
index 971340d6..00000000
--- a/deploy.sh
+++ /dev/null
@@ -1 +0,0 @@
-deploy/deploy-rylween.sh
\ No newline at end of file
diff --git a/deploy/.env.example b/deploy/.env.example
index 89aac834..5b44bbfb 100644
--- a/deploy/.env.example
+++ b/deploy/.env.example
@@ -3,16 +3,17 @@
# next to them and uncomment what you change; commented lines show the
# defaults. Variables exported in the shell take precedence over .env.
-# For ./deploy.sh --https and compose.https.yaml only: the name players open,
+# For ./rylween serve --https and compose.https.yaml only: the name players open,
# whose DNS points at this machine. compose.yaml ignores it. README.md here
# explains what HTTPS needs.
# RYLWEEN_DOMAIN=rylween.example.net
-# Host address and port to publish on. The root ./deploy.sh detects this
-# machine's LAN address unless .env sets the address; plain `docker compose up`
-# publishes on 127.0.0.1.
+# Host address and ports to publish on. 127.0.0.1 keeps the game to this
+# machine; `./rylween serve --lan` publishes on this machine's LAN address
+# instead, and --local or --host override what this file sets.
# RYLWEEN_PUBLISH_HOST=127.0.0.1
RYLWEEN_HOST_PORT=8081
+# RYLWEEN_ANSI_HOST_PORT=8080
# Named volume or host directory (./path, ~/path, /path) for saves, accounts,
# and logs. A ./path is relative to deploy/.
diff --git a/deploy/README.md b/deploy/README.md
index 812850a8..0ffb51db 100644
--- a/deploy/README.md
+++ b/deploy/README.md
@@ -1,156 +1,204 @@
-# Deploying Rylween
-
-`deploy/` holds everything for running the bitmap game as a server, for
-players who open it in a browser. The ANSI terminal game needs no server; see
-[`bin/README.md`](../bin/README.md).
-
-## Which Way
-
-| Players are | Over | Run | The machine needs |
-|---|---|---|---|
-| On this machine | HTTP | the one `docker run` in the [README](../README.md#with-only-docker-or-podman) | Docker or Podman |
-| On your local network | HTTP | `./deploy.sh`, with `compose.yaml` | a checkout, and Docker or Podman |
-| On the internet | HTTPS | `compose.https.yaml`, or `./deploy.sh --https` | a public address, a domain name, ports 80 and 443, and Docker or Podman |
-
-Never put the plain HTTP setups on the internet: passwords and cookies would
-cross it in plain text.
+# Running Rylween
+
+`./rylween`, in the repository root, runs the game every way it runs: the ANSI
+game in a terminal, and either game as a server for browsers, on this machine,
+your local network, or the internet over HTTPS. It is a link to
+`deploy/rylween`, which lives here with the compose files and images it uses.
+
+## The `rylween` Command
+
+| Command | What it does |
+|---|---|
+| `./rylween` | Plays the ANSI game in this terminal. |
+| `./rylween serve` | Hosts the bitmap game for browsers on this machine, at `http://127.0.0.1:8081/`, in a container built from the checkout. |
+| `./rylween serve --lan` | The same, for every machine on your local network. |
+| `./rylween serve --https` | The released bitmap game on the internet, behind Caddy and HTTPS; see [On The Internet, Over HTTPS](#on-the-internet-over-https). |
+| `./rylween stop` | Stops whatever `serve` started. |
+| `./rylween backup` | Archives saves and accounts; see [Backups](#backups). |
+| `./rylween help` | Lists every option. |
+
+`serve` takes one choice from each row; with none given it uses the defaults:
+
+| Choice | Options | Default |
+|---|---|---|
+| The game | `--bitmap`, the painted version, or `--ansi`, the ANSI version in the browser | `--bitmap` |
+| Where it runs | `--docker`, in a container (Docker or Podman), or `--no-docker`, with the launcher built from the checkout, which needs a JDK | `--docker` |
+| The protocol | `--http`, or `--https` for the internet | `--http` |
+| Who can connect | `--local`, this machine only; `--lan`, the local network, on this machine's LAN address; or `--host ADDRESS` | `--local` |
+| The port | `--port PORT` | 8081 for the bitmap game, 8080 for the ANSI game |
+
+`--local` is the default so that nothing is reachable from other machines
+unless you ask for it with `--lan`. (The `./deploy.sh` this command replaces
+published on the LAN by default.) `serve` returns once the server answers and
+prints its address; `--foreground` stays attached to the server's output
+instead, and Ctrl-C stops it. `--https` works with the bitmap game in
+containers only, for now.
+
+Without a checkout there is no `rylween` command, and none is needed: the
+[README](../README.md#with-only-docker-or-podman) runs the released game with
+one `docker run`, each release's terminal zip plays with its `bin/rylween`
+(this same script, which there only plays), and an HTTPS server needs only
+[`compose.https.yaml`](#4-get-the-compose-file).
## What Is Here
-- **`compose.yaml`** builds the bitmap game's image from the checkout and runs
- it over plain HTTP, with its data on a persistent volume, published on
- `127.0.0.1:8081` or, through `./deploy.sh`, on the LAN address.
-- **`compose.https.yaml`** runs the released image behind Caddy, which gets the
- certificate and serves HTTPS. Each GitHub release attaches a copy pinned to
- that release, so an HTTPS server needs no checkout.
-- **`deploy-rylween.sh`**, also `./deploy.sh` in the repository root, starts
- either one and waits until it answers: `--compose`, the default, for the LAN;
- `--https` for the internet; `--launcher` for the installed launcher without
- Docker.
+- **`rylween`**, the command above.
+- **`compose.yaml`** builds and runs the game for `serve` over plain HTTP: the
+ bitmap game, and the ANSI game in its `ansi` profile. Its header lists every
+ setting.
+- **`compose.https.yaml`** runs the released bitmap image behind Caddy for
+ `serve --https`. Each GitHub release attaches a copy pinned to that release, so
+ an HTTPS server needs no checkout.
- **`.env.example`** shows the settings both compose files read from a `.env`
- file next to them.
-- **`docker/`** holds the Dockerfiles:
- - `Dockerfile.bitmap-production` builds the bitmap game, serving port 8081.
- Releases publish it as `ghcr.io/lagergren/rylween:X.Y.Z` and `:latest`,
- for linux/amd64 and linux/arm64. Its builder stage runs on the build
- machine's own platform, so an image for another platform needs no
- emulation.
- - `Dockerfile.production` builds the ANSI game for the browser, serving port
- 8080, and `Dockerfile` the same for `bin/run-server.sh`.
-
-Build them from the repository root, which Gradle, the sources, and the root
-`.dockerignore` need as the build context:
+ file here.
+- **`docker/Dockerfile.bitmap`** builds the bitmap game, serving port 8081.
+ Releases publish it as `ghcr.io/lagergren/rylween:X.Y.Z` and `:latest`, for
+ linux/amd64 and linux/arm64. Its builder stage runs on the build machine's
+ own platform, so an image for another platform needs no emulation.
+- **`docker/Dockerfile.ansi`** builds the ANSI game for the browser, serving
+ port 8080.
+
+Both images serve plain HTTP inside the container and keep saves, accounts, and
+logs under their `/data` volume. They mark the login cookie `Secure`, for
+HTTPS (`RYLWEEN_AUTH_SECURE_COOKIES=true`), so browsers keep it only over HTTPS;
+the plain HTTP setups here set it to `false`. Once the bitmap server accepts
+connections it prints the link to open, taken from `RYLWEEN_PUBLIC_URL`, or
+`localhost` and its port. Build an image by hand from the repository root, which
+Gradle, the sources, and the root `.dockerignore` need as the build context:
```sh
-docker build -f deploy/docker/Dockerfile.bitmap-production -t rylween-bitmap-prod .
-docker build -f deploy/docker/Dockerfile.production -t rylween-web-prod .
+docker build -f deploy/docker/Dockerfile.bitmap -t rylween-bitmap .
```
-Every image serves plain HTTP inside the container and keeps saves, accounts,
-and logs under its `/data` volume. The production images mark the login cookie
-`Secure` (`RYLWEEN_AUTH_SECURE_COOKIES=true`), so browsers keep it only over
-HTTPS; plain HTTP setups set it to `false`. Run directly, the bitmap image uses
-an 8x8 wilderness view at 64 px per tile, while the compose files and the
-launcher default to 6x6 at 68 px. Once the bitmap server accepts connections it
-prints the link to open, taken from `RYLWEEN_PUBLIC_URL`, or `localhost` and its
-port.
+## Playing In A Terminal
-## On Your Network, Over HTTP
+```sh
+./rylween
+./rylween --name Strong
+./rylween --name StrongEndgame
+```
-`compose.yaml` builds `Dockerfile.bitmap-production` and runs the game. Run
-compose from `deploy/`, or pass `-f deploy/compose.yaml` from the repository
-root:
+The first run builds the game, `build/compiled/rylween-bundle.json` and
+`:runtime:installRuntime`, and `--build` rebuilds it; it needs JDK 23 or newer,
+and Gradle downloads the JDK 25 toolchain the modules build with. The game runs
+outside Gradle, from a private copy of the install, so Gradle's output does not
+share the game screen and a rebuild cannot pull jars from under a running game.
+The shared save is `~/.rylween/data/saves/world.rsave` and the log
+`~/.rylween/data/logs/runtime/latest.log`, unless `RYLWEEN_DATA_DIR`,
+`RYLWEEN_SAVE_FILE`, or `RYLWEEN_LOG_FILE` say otherwise.
+
+It shows the title screen by default. `--name Strong` loads a seeded party
+outside Thord, and `--name StrongEndgame` one two steps north of Castle Ydarg
+with the five power artifacts. `--no-title` skips the title screen to boot a
+state or feed a script. Other options go to the game: `--seed N`, `--state SLUG`,
+`--script KEYS`, `--load FILE`, `--save FILE`, and `--log FILE`, which keeps a
+named capture instead of replacing `latest.log`. For forensics, `--debug-log`
+flashes the latest log line below the game frame, and `--debug-secrets` enables
+hidden wilderness keys: `[` forces a cave discovery, `]` a random encounter, and
+`M` shows the whole world map.
```sh
-cd deploy
-docker compose up --build -d # or: podman compose up --build -d
-docker compose logs -f rylween
-docker compose down # keeps the volume
+./rylween --screen title
+./rylween --no-title --script 22SX --save build/saves/runtime.rsave
+./rylween --name Strong --debug-log --debug-secrets
```
-On macOS with Podman, start its VM first with `podman machine start`.
+The installed launcher also runs by itself, with every option spelled out:
-The container publishes on `127.0.0.1:8081` by default. To let other machines
-on the local network connect, run it through the deploy script. It builds the
-image, detects this machine's private LAN address, publishes on it, waits
-until the server answers, and prints the address with the commands for the
-sysop password, the log, and `down`:
+```sh
+runtimes/runtime/build/install/rylween/bin/rylween --bundle build/compiled/rylween-bundle.json --user local --state fresh-replay --seed 1
+```
+
+## On This Machine Or Your Network, Over HTTP
+
+### In A Container: The Default
```sh
-./deploy.sh # from the repository root
-./deploy-rylween.sh # from deploy/; the same script
+./rylween serve # this machine only
+./rylween serve --lan # every machine on the local network
+./rylween serve --ansi # the ANSI game for the browser, on port 8080
```
+`serve` builds the image from the checkout with Docker Compose (Podman Compose
+when Docker is missing), starts it with `compose.yaml`, waits until the server
+answers, and prints the address with the commands for the sysop password, the
+log, and stopping it:
+
```text
-Rylween is up on http://192.168.1.20:8081/
+Rylween is up on http://127.0.0.1:8081/
Sysop password: docker compose -f /path/to/rylween/deploy/compose.yaml exec rylween cat /data/auth/admin-password.txt
Server log: docker compose -f /path/to/rylween/deploy/compose.yaml logs -f rylween
- Stop: docker compose -f /path/to/rylween/deploy/compose.yaml down
+ Stop: /path/to/rylween/rylween stop
```
-The build runs inside the image, so the host needs only Docker or Podman, not
-a JDK. Run `./deploy.sh` again after pulling changes to rebuild and restart; a
-plain `docker compose up` would publish on `127.0.0.1` only.
+The build runs inside the image, so the machine needs only Docker or Podman,
+not a JDK. Run `serve` again after pulling changes to rebuild and restart. On
+macOS with Podman, start its VM first with `podman machine start`.
-Or set `RYLWEEN_PUBLISH_HOST` yourself, to a LAN address such as `192.168.x.y`
-or to `0.0.0.0`; `RYLWEEN_HOST_PORT` changes the port. When `deploy/.env` sets
-`RYLWEEN_PUBLISH_HOST`, the deploy script uses that address instead of
-detecting one. Compose sets `RYLWEEN_AUTH_SECURE_COOKIES=false`, so logins work
-over plain HTTP. All settings are listed at the top of `compose.yaml` and can
-be kept in an uncommitted `deploy/.env`; copy `deploy/.env.example`, which
-shows each one at its default.
+`--lan` publishes on this machine's private LAN address, for example
+`http://192.168.1.20:8081/`, and refuses to pick a public one. `--host ADDRESS`
+publishes on the address given, such as `0.0.0.0` for every interface, and
+`--port PORT` on another port. Without any of them, `RYLWEEN_PUBLISH_HOST` in
+the shell or `deploy/.env` decides, and otherwise `127.0.0.1`.
-Saves, accounts, and logs live on the `rylween_data` volume. They survive
-`down`, rebuilds, and image updates; only `down -v` or `volume rm` deletes
-them. To keep them in a host directory instead, for example to back them up
-with `bin/backup-web-data.sh`, point `RYLWEEN_DATA_VOLUME` at it. A relative
-path such as `./data` is relative to `deploy/`. From the repository root:
+Settings come from `deploy/.env`, which `compose.yaml`'s header and
+`.env.example` describe: copy `.env.example` to start one. Saves, accounts,
+and logs live on the `rylween_data` volume (`rylween_ansi-data` for the ANSI
+game). They survive restarts, rebuilds, and image updates; only
+`docker compose down -v` or `volume rm` deletes them. To keep them in a host
+directory instead, point `RYLWEEN_DATA_VOLUME` at it; a relative path such as
+`./data` is relative to `deploy/`. Compose can also run directly from `deploy/`:
```sh
-mkdir -p ~/.rylween/compose-data
-echo 'RYLWEEN_DATA_VOLUME=~/.rylween/compose-data' >> deploy/.env
-./deploy.sh
-bin/backup-web-data.sh --data ~/.rylween/compose-data --output rylween-backup.tar.gz
+cd deploy
+docker compose up --build -d # or: podman compose up --build -d
+docker compose logs -f rylween
+docker compose down # keeps the volumes
```
On first start the server creates the sysop account (`RYLWEEN_ADMIN_ACCOUNT`,
default `admin`), which gets the game's secret wilderness keys and which
players cannot register. Unless `RYLWEEN_ADMIN_PASSWORD` is set, its generated
-password is saved in `/data/auth/admin-password.txt`:
+password is saved in `/data/auth/admin-password.txt`, which the
+`Sysop password` command prints.
+
+### Without Docker: `--no-docker`
```sh
-docker compose exec rylween cat /data/auth/admin-password.txt
+./rylween serve --no-docker
+./rylween serve --no-docker --name StrongEndgame --debug-secrets
+./rylween serve --no-docker --ansi --name Strong
+./rylween serve --no-docker --account Strong --email strong@example.test --password 'change-this-password'
```
-### Without Docker: `--launcher`
+This runs the launcher built from the checkout, `--build` rebuilds it, and it
+needs a JDK. It keeps its data in `~/.rylween/data`, the terminal game's, or in
+`--data DIR`, and its output in `logs/serve-bitmap.console.log` (or
+`serve-ansi`) there. `--name Strong` or `--name StrongEndgame` seeds that test
+party into the shared save first and logs the browser in as it, without an
+account. `--account` with `--password` (and optionally `--email`) creates or
+verifies an account before the server starts. Other options go to the server,
+such as `--debug-secrets`, `--map-tiles N`, and `--tile-size PX` for the bitmap
+game; `--help` on the installed launchers lists them all. `--lan`, `--host`, and
+`--port` work as with containers. The server keeps running in the background
+until `./rylween stop`, and a new `serve` replaces the earlier one.
-`./deploy.sh --launcher` starts the installed bitmap launcher in the background
-instead, with its own data directory, `~/.rylween/deploy`, and its log in
-`/tmp/rylween-bitmap-web-deploy.log`. Build the launcher first:
+## Backups
```sh
-./gradlew :runtime-bitmap-web:installRuntimeBitmapWeb --console=plain
-./deploy.sh --launcher
+./rylween backup # ~/.rylween/data: the terminal game and --no-docker
+./rylween backup --volume rylween_data # ./rylween serve
+./rylween backup --volume rylween-https_data # ./rylween serve --https
+./rylween backup --data DIR --output rylween-backup.tar.gz --include-logs
```
-It binds to the private LAN address of the interface carrying the default
-route, so other machines on the network can connect without it listening on
-every interface, and it refuses to pick a public address on its own. It prints
-the address, for example `http://192.168.1.20:8081`. Rerunning it stops the
-server it started before, and it refuses to start when the launcher is not
-installed. On Linux it uses `ip`, `/proc`, and `setsid`; on macOS, `route`,
-`ifconfig`, `ps`, and `nohup`.
-
-`RYLWEEN_DEPLOY_HOST` sets the bind address instead, such as `127.0.0.1`. Use
-`0.0.0.0` only when the server should listen on every IPv4 interface.
-`RYLWEEN_DEPLOY_PORT`, `RYLWEEN_DEPLOY_DATA_DIR`, and `RYLWEEN_DEPLOY_LOG_FILE`
-set the port (default `8081`), the data directory, and the log file, and
-`RYLWEEN_DEPLOY_APP` points the script at another installed launcher. The
-sysop account's generated password is in
-`~/.rylween/deploy/auth/admin-password.txt`. Without `--launcher`,
-`RYLWEEN_DEPLOY_HOST` still picks the address, and compose's
-`RYLWEEN_HOST_PORT` and `RYLWEEN_DATA_VOLUME` take the place of the port and
-data settings.
+The archive holds the shared save (`saves/`) and the accounts (`auth/users/`),
+and with `--include-logs` the logs, which can be large and record players'
+activity. The generated sysop password is left out; the sysop account itself
+survives a restore. A volume is read through a throwaway `alpine` container.
+Restore by unpacking the archive into the data directory, or into the volume,
+while the server is stopped. [`runtimes/web-common/README.md`](../runtimes/web-common/README.md)
+describes what each file holds.
## On The Internet, Over HTTPS
@@ -179,7 +227,7 @@ The pieces:
- **`compose.https.yaml`** runs the released game image behind Caddy. The game
publishes no port; only Caddy listens on 80 and 443. Its header lists every
setting.
-- **`./deploy.sh --https`**, from a checkout, pulls the latest release, starts
+- **`./rylween serve --https`**, from a checkout, pulls the latest release, starts
`compose.https.yaml`, waits until the site answers over HTTPS with a valid
certificate, and prints the address and the commands to manage it.
- **A `compose.https.yaml` attached to each release**, pinned to that release's
@@ -245,7 +293,7 @@ What Caddy does:
5. **Docker or Podman.** Docker Engine with the Compose plugin is the
recommended choice: run as root, it lets the game see players' real
addresses (see [step 9](#9-check-players-addresses)). Podman 4 or newer, with
- `podman compose`, works too. git is needed only for `./deploy.sh --https` from
+ `podman compose`, works too. git is needed only for `./rylween serve --https` from
a checkout.
6. **Certificates: nothing to do.** You don't buy, create, or copy any. Caddy
gets them from Let's Encrypt, which first checks that you control the name by
@@ -341,7 +389,7 @@ applies to both.
docker compose -f compose.https.yaml up -d
```
-Or, from a checkout, `./deploy.sh --https`. It pulls the latest release,
+Or, from a checkout, `./rylween serve --https`. It pulls the latest release,
starts both containers, waits up to three minutes for a valid certificate, and
prints:
@@ -350,7 +398,7 @@ Rylween is up on https://rylween.example.net/
Sysop password: docker compose -f .../deploy/compose.https.yaml exec rylween cat /data/auth/admin-password.txt
Server log: docker compose -f .../deploy/compose.https.yaml logs -f rylween
Proxy log: docker compose -f .../deploy/compose.https.yaml logs -f caddy
- Stop: docker compose -f .../deploy/compose.https.yaml down
+ Stop: .../rylween stop
```
#### 7. Watch the certificate arrive
@@ -418,11 +466,13 @@ everyone for 15 minutes. Run Docker or Podman as root to fix it.
`/data/logs/runtime-bitmap-web/`. `docker compose -f compose.https.yaml logs caddy`
shows Caddy's access log.
- **Backups.** Archive the game's volume, which Compose names
- `rylween-https_data`:
+ `rylween-https_data`: from a checkout with
+ `./rylween backup --volume rylween-https_data` (see [Backups](#backups)), or
+ without one:
```sh
docker run --rm -v rylween-https_data:/data:ro -v "$PWD":/backup alpine \
- tar czf /backup/rylween-$(date +%F).tar.gz -C /data .
+ tar czf /backup/rylween-$(date +%F).tar.gz -C /data saves auth/users
```
- **Stopping.** `docker compose -f compose.https.yaml down` stops both and keeps
@@ -446,7 +496,7 @@ It does not cover:
passwords still matter, the sysop's most of all.
- Failed-login counts across restarts. They live in memory.
- A second factor. Accounts are a name, an email, and a password.
-- The ANSI game for the browser (`docker/Dockerfile.production`). It has none of
+- The ANSI game for the browser (`docker/Dockerfile.ansi`). It has none of
the same-origin check, the login limit, or the proxy trust, so put the bitmap
game on the internet instead.
- The machine itself. Keep it updated, log in with SSH keys, and open no ports
@@ -454,7 +504,7 @@ It does not cover:
### Troubleshooting
-- **No certificate, or `./deploy.sh --https` times out.** Caddy's log says why:
+- **No certificate, or `./rylween serve --https` times out.** Caddy's log says why:
`docker compose -f compose.https.yaml logs caddy`. Usually DNS does not yet
point at the machine (`dig +short rylween.example.net`), or port 80 or 443
does not reach it. Check from outside your network, for example
@@ -530,25 +580,18 @@ image without Caddy, published only to `127.0.0.1` or a private network, and:
### The ANSI Game In The Browser
-`docker/Dockerfile.production` packages the ANSI game for the browser, which
-serves port 8080 and lets one player at a time play. It has none of the bitmap
-server's same-origin check, failed-login limit, or proxy trust, so keep it to
-players you know. Publish it only to `127.0.0.1`, and keep its secrets in a file
-rather than on the command line, where shell history and process listings would
-keep them:
+The ANSI game for the browser lets one player at a time play, and has none of
+the bitmap server's same-origin check, failed-login limit, or proxy trust, so
+keep it to players you know. To serve it over HTTPS, run it on this machine
+only, with secure cookies, by setting `RYLWEEN_AUTH_SECURE_COOKIES=true` in
+`deploy/.env` (which applies to the bitmap game in `compose.yaml` too):
```sh
-docker build -f deploy/docker/Dockerfile.production -t rylween-web-prod .
-sudo install -d -m 700 /etc/rylween
-sudo install -m 600 /dev/null /etc/rylween/rylween.env
-sudoedit /etc/rylween/rylween.env # RYLWEEN_ADMIN_PASSWORD=...
-docker run -d --name rylween-web --restart unless-stopped \
- --env-file /etc/rylween/rylween.env -p 127.0.0.1:8080:8080 \
- -v rylween-web-data:/data rylween-web-prod
+./rylween serve --ansi # publishes on 127.0.0.1:8080
```
-Then serve it over HTTPS from Caddy installed on the machine, with a
-`Caddyfile` such as:
+Then put Caddy, installed on the machine, in front of it, with a `Caddyfile`
+such as:
```caddyfile
rylween.example.net {
@@ -564,7 +607,7 @@ rylween.example.net {
Its server log is `/data/logs/web-server.log`, and each session writes
`/data/logs/-.log`. Both are echoed to its standard
-output, so `docker logs rylween-web` shows them.
+output, which `docker compose -f deploy/compose.yaml logs rylween-ansi` shows.
### Without A Public Address: Tailscale
diff --git a/deploy/compose.https.yaml b/deploy/compose.https.yaml
index 46fafa94..c4f9f83c 100644
--- a/deploy/compose.https.yaml
+++ b/deploy/compose.https.yaml
@@ -7,7 +7,7 @@
# docker compose -f compose.https.yaml up -d # or: podman compose ...
# open https:/// and register an account
#
-# From a checkout, ./deploy.sh --https runs it and waits until it answers.
+# From a checkout, ./rylween serve --https runs it and waits until it answers.
#
# Settings, from the shell environment or .env next to this file:
# RYLWEEN_DOMAIN Required. The name players open, whose DNS points
diff --git a/deploy/compose.yaml b/deploy/compose.yaml
index 3e8ef4be..867e54f2 100644
--- a/deploy/compose.yaml
+++ b/deploy/compose.yaml
@@ -1,25 +1,33 @@
-# Runs the bitmap web game. Saves, accounts, and logs live on a persistent
-# volume mounted at /data, so they survive `down`, rebuilds, and image updates.
+# Runs the game for browsers over plain HTTP, built from this checkout: the
+# bitmap game, and, with the `ansi` profile, the ANSI game. Saves, accounts, and
+# logs live on persistent volumes mounted at /data, so they survive `down`,
+# rebuilds, and image updates.
#
-# docker compose -f deploy/compose.yaml up --build -d # or: podman compose ...
-# open http://127.0.0.1:8081/ and register an account
+# ./rylween serve [--ansi] [--lan] # from the repository root; see deploy/README.md
#
-# From inside deploy/, plain `docker compose up --build -d` works too.
+# or compose itself, from deploy/:
#
-# Rebuild with --build after pulling new game code. `down -v` deletes the volume
-# and with it every save and account.
+# docker compose up --build -d # the bitmap game
+# docker compose --profile ansi up --build -d rylween-ansi # the ANSI game
+# open http://127.0.0.1:8081/ (ANSI: 8080) and register an account
+#
+# Rebuild with --build after pulling new game code. `down -v` deletes the volumes
+# and with them every save and account.
#
# Settings come from the shell environment or a .env file next to this file
# (copy .env.example to start one):
-# RYLWEEN_PUBLISH_HOST Host address to publish on. Default: 127.0.0.1.
-# The root ./deploy.sh (deploy-rylween.sh here)
-# sets it to this machine's LAN address so others
-# on the local network can connect; 0.0.0.0
-# publishes on every interface.
-# RYLWEEN_HOST_PORT Host port. Default: 8081
+# RYLWEEN_PUBLISH_HOST Host address to publish on. Default: 127.0.0.1,
+# this machine only. `./rylween serve --lan` sets it
+# to this machine's LAN address so others on the
+# local network can connect; 0.0.0.0 publishes on
+# every interface.
+# RYLWEEN_HOST_PORT The bitmap game's host port. Default: 8081
+# RYLWEEN_ANSI_HOST_PORT The ANSI game's host port. Default: 8080
# RYLWEEN_DATA_VOLUME Named volume or host directory (./path, ~/path, /path)
-# mounted at /data; ./path is relative to deploy/.
-# Default: the `data` named volume.
+# mounted at /data for the bitmap game; ./path is
+# relative to deploy/. Default: the `data` volume.
+# RYLWEEN_ANSI_DATA_VOLUME The same for the ANSI game. Default: the
+# `ansi-data` volume.
# RYLWEEN_BITMAP_STATE Initial compiled state slug. Default: fresh-replay
# RYLWEEN_BITMAP_MAP_TILES Wilderness viewport edge length. Default: 6
# RYLWEEN_BITMAP_TILE_SIZE Wilderness tile size in px. Default: 68
@@ -43,11 +51,13 @@ services:
build:
# The repository root, which the Dockerfile copies the sources from.
context: ..
- dockerfile: deploy/docker/Dockerfile.bitmap-production
+ dockerfile: deploy/docker/Dockerfile.bitmap
restart: unless-stopped
ports:
- "${RYLWEEN_PUBLISH_HOST:-127.0.0.1}:${RYLWEEN_HOST_PORT:-8081}:8081"
environment:
+ # The link the server prints once it is up.
+ RYLWEEN_PUBLIC_URL: http://${RYLWEEN_PUBLISH_HOST:-127.0.0.1}:${RYLWEEN_HOST_PORT:-8081}
RYLWEEN_BITMAP_STATE: ${RYLWEEN_BITMAP_STATE:-fresh-replay}
RYLWEEN_BITMAP_MAP_TILES: ${RYLWEEN_BITMAP_MAP_TILES:-6}
RYLWEEN_BITMAP_TILE_SIZE: ${RYLWEEN_BITMAP_TILE_SIZE:-68}
@@ -62,5 +72,28 @@ services:
volumes:
- ${RYLWEEN_DATA_VOLUME:-data}:/data
+ # The ANSI game for the browser, started only with the `ansi` profile, which
+ # `./rylween serve --ansi` passes. One player plays at a time.
+ rylween-ansi:
+ profiles:
+ - ansi
+ build:
+ context: ..
+ dockerfile: deploy/docker/Dockerfile.ansi
+ restart: unless-stopped
+ ports:
+ - "${RYLWEEN_PUBLISH_HOST:-127.0.0.1}:${RYLWEEN_ANSI_HOST_PORT:-8080}:8080"
+ environment:
+ RYLWEEN_AUTH_SECURE_COOKIES: ${RYLWEEN_AUTH_SECURE_COOKIES:-false}
+ RYLWEEN_AUTH_ACCOUNT: ${RYLWEEN_AUTH_ACCOUNT:-}
+ RYLWEEN_AUTH_EMAIL: ${RYLWEEN_AUTH_EMAIL:-}
+ RYLWEEN_AUTH_PASSWORD: ${RYLWEEN_AUTH_PASSWORD:-}
+ RYLWEEN_ADMIN_ACCOUNT: ${RYLWEEN_ADMIN_ACCOUNT:-admin}
+ RYLWEEN_ADMIN_PASSWORD: ${RYLWEEN_ADMIN_PASSWORD:-}
+ RYLWEEN_VICTIM_ACCOUNT: ${RYLWEEN_VICTIM_ACCOUNT:-}
+ volumes:
+ - ${RYLWEEN_ANSI_DATA_VOLUME:-ansi-data}:/data
+
volumes:
data:
+ ansi-data:
diff --git a/deploy/deploy-rylween.sh b/deploy/deploy-rylween.sh
deleted file mode 100755
index 2781c069..00000000
--- a/deploy/deploy-rylween.sh
+++ /dev/null
@@ -1,286 +0,0 @@
-#!/usr/bin/env bash
-# Rebuilds the bitmap web game's image and (re)starts it with docker compose
-# (podman compose when docker is missing), published on this machine's private
-# LAN address so others on the local network can connect, then waits until the
-# server answers and prints its address. Settings come from compose.yaml and
-# .env next to this script. The repository root's deploy.sh is a symlink to
-# this script, so `./deploy.sh` there and `./deploy-rylween.sh` here are the
-# same command, and either works from any directory.
-#
-# --launcher skips Docker and starts the installed bitmap launcher in the
-# background instead. --compose names the default explicitly. --https runs the
-# released image on the internet behind Caddy and HTTPS instead, with
-# compose.https.yaml; deploy/README.md explains what that needs.
-set -euo pipefail
-
-# Follow symlinks such as the root deploy.sh, so DEPLOY_DIR is the directory
-# holding this script and compose.yaml rather than the one holding the link.
-script="$0"
-while [ -L "$script" ]; do
- target="$(readlink "$script")"
- case "$target" in
- /*) script="$target" ;;
- *) script="$(dirname "$script")/$target" ;;
- esac
-done
-DEPLOY_DIR="$(cd "$(dirname "$script")" && pwd)"
-ROOT_DIR="$(dirname "$DEPLOY_DIR")"
-
-APP="${RYLWEEN_DEPLOY_APP:-$ROOT_DIR/runtimes/runtime-bitmap-web/build/install/rylween-bitmap-web/bin/rylween-bitmap-web}"
-HOST="${RYLWEEN_DEPLOY_HOST:-lan}"
-PORT="${RYLWEEN_DEPLOY_PORT:-8081}"
-DATA_DIR="${RYLWEEN_DEPLOY_DATA_DIR:-$HOME/.rylween/deploy}"
-LOG_FILE="${RYLWEEN_DEPLOY_LOG_FILE:-/tmp/rylween-bitmap-web-deploy.log}"
-MAIN_CLASS="${RYLWEEN_DEPLOY_MAIN_CLASS:-rylween.bitmapweb.RylweenBitmapWebRuntimeMainKt}"
-
-# At most one argument, the mode; compose is the default.
-case "$#:${1-}" in
- 0: | 1:--compose) MODE=compose ;;
- 1:--launcher) MODE=launcher ;;
- 1:--https) MODE=https ;;
- *)
- echo "usage: $0 [--compose | --launcher | --https]" >&2
- exit 2
- ;;
-esac
-
-# Address of the interface carrying the default route, i.e. the one other
-# machines on the local network can reach.
-detect_lan_host() {
- local host="" iface
- if command -v ip >/dev/null 2>&1; then
- host="$(
- ip -4 route get 1.1.1.1 2>/dev/null |
- awk '{ for (i = 1; i < NF; i++) if ($i == "src") { print $(i + 1); exit } }'
- )"
- fi
-
- # macOS has no `ip`; ask the routing table for the default interface instead.
- if [ -z "$host" ] && command -v route >/dev/null 2>&1; then
- iface="$(route -n get default 2>/dev/null | awk '$1 == "interface:" { print $2; exit }')"
- if [ -n "$iface" ]; then
- host="$(ifconfig "$iface" 2>/dev/null | awk '$1 == "inet" { print $2; exit }')"
- fi
- fi
-
- # Only bind automatically to a private (RFC 1918) address, never a public one.
- case "$host" in
- 10.*|192.168.*|172.1[6-9].*|172.2[0-9].*|172.3[01].*)
- echo "$host"
- ;;
- *)
- return 1
- ;;
- esac
-}
-
-resolve_host() {
- case "$HOST" in
- lan)
- detect_lan_host
- ;;
- *)
- echo "$HOST"
- ;;
- esac
-}
-
-is_deployed_server() {
- local has_main=false has_port=false has_data=false
- while [ "$#" -gt 0 ]; do
- case "$1" in
- "$MAIN_CLASS") has_main=true ;;
- --port) [ "${2-}" != "$PORT" ] || has_port=true ;;
- --data) [ "${2-}" != "$DATA_DIR" ] || has_data=true ;;
- esac
- shift
- done
- [ "$has_main" = true ] && [ "$has_port" = true ] && [ "$has_data" = true ]
-}
-
-find_existing_pids() {
- if [ -d /proc/self ]; then
- find_existing_pids_proc
- else
- find_existing_pids_ps
- fi
-}
-
-find_existing_pids_proc() {
- local cmdline pid arg
- local -a args
- for cmdline in /proc/[0-9]*/cmdline; do
- [ -r "$cmdline" ] || continue
- pid="${cmdline#/proc/}"
- pid="${pid%/cmdline}"
- [ "$pid" != "$$" ] || continue
- args=()
- # Preserve argument boundaries, including spaces in data directory names.
- while IFS= read -r -d '' arg; do
- args+=("$arg")
- done < "$cmdline" 2>/dev/null || continue
- if is_deployed_server "${args[@]}"; then
- printf '%s\n' "$pid"
- fi
- done
- return 0
-}
-
-# Without /proc (macOS), ps joins arguments with single spaces, so match each
-# expected argument pair as a space-delimited substring of the command line.
-find_existing_pids_ps() {
- local pid command
- while read -r pid command; do
- [ "$pid" != "$$" ] || continue
- case " $command " in *" $MAIN_CLASS "*) ;; *) continue ;; esac
- case " $command " in *" --port $PORT "*) ;; *) continue ;; esac
- case " $command " in *" --data $DATA_DIR "*) ;; *) continue ;; esac
- printf '%s\n' "$pid"
- done < <(ps -axww -o pid= -o command=)
- return 0
-}
-
-start_detached() {
- if command -v setsid >/dev/null 2>&1; then
- setsid -f "$@" > "$LOG_FILE" 2>&1
- else
- # macOS has no setsid. nohup ignores SIGHUP so the server outlives the
- # terminal; a non-interactive shell already starts `&` jobs with SIGINT ignored.
- nohup "$@" < /dev/null > "$LOG_FILE" 2>&1 &
- fi
-}
-
-stop_existing_server() {
- local pids
- pids="$(find_existing_pids)"
- [ -z "$pids" ] && return 0
-
- echo "Stopping existing deployed bitmap server: $pids"
- kill $pids
-
- for _ in {1..30}; do
- pids="$(find_existing_pids)"
- [ -z "$pids" ] && return 0
- sleep 0.2
- done
-
- echo "Existing server did not exit cleanly; forcing: $pids"
- kill -9 $pids
-}
-
-# Waits up to a minute, or $2 seconds, for any HTTP answer from the URL in $1;
-# /api/status answers 401 without a login, which is enough. An HTTPS URL counts
-# only once its certificate checks out. `compose up -d` returns as soon
-# as the container starts, seconds before the server in it listens, and the
-# container port forwarder may accept connections before then, so only an HTTP
-# response shows the server is up. Without curl it cannot tell and does not wait.
-wait_for_http() {
- local url="$1" deadline=$((SECONDS + ${2:-60}))
- command -v curl >/dev/null 2>&1 || return 0
- until curl --noproxy '*' --silent --output /dev/null --max-time 2 "$url"; do
- [ "$SECONDS" -lt "$deadline" ] || return 1
- sleep 1
- done
-}
-
-# HTTPS mode runs compose.https.yaml: the released image, behind Caddy, which
-# gets a certificate for RYLWEEN_DOMAIN from Let's Encrypt. It waits until the
-# site answers over HTTPS, which includes the time the first certificate takes.
-if [ "$MODE" = https ]; then
- cd "$DEPLOY_DIR"
- domain="${RYLWEEN_DOMAIN-}"
- if [ -z "$domain" ] && [ -f .env ]; then
- domain="$(sed -n 's/^[[:space:]]*RYLWEEN_DOMAIN=//p' .env | tail -n 1 | tr -d "\"' ")"
- fi
- if [ -z "$domain" ]; then
- echo "Set RYLWEEN_DOMAIN, the name players open, in $DEPLOY_DIR/.env or the shell." >&2
- echo "$DEPLOY_DIR/README.md explains what the name needs." >&2
- exit 2
- fi
- engine=(docker compose)
- command -v docker >/dev/null 2>&1 || engine=(podman compose)
- compose=("${engine[@]}" -f "$DEPLOY_DIR/compose.https.yaml")
- "${compose[@]}" pull
- "${compose[@]}" up -d
-
- printf -v manage '%s -f %q' "${engine[*]}" "$DEPLOY_DIR/compose.https.yaml"
- if ! wait_for_http "https://$domain/healthz" 180; then
- echo "https://$domain/ did not answer within 3 minutes. Check that DNS for $domain" >&2
- echo "points at this host and that ports 80 and 443 reach it. Caddy's log says why:" >&2
- echo " $manage logs caddy" >&2
- exit 1
- fi
- echo "Rylween is up on https://$domain/"
- echo " Sysop password: $manage exec rylween cat /data/auth/admin-password.txt"
- echo " Server log: $manage logs -f rylween"
- echo " Proxy log: $manage logs -f caddy"
- echo " Stop: $manage down"
- exit 0
-fi
-
-# Compose mode builds and runs the image instead of the installed launcher. It
-# publishes on the detected LAN address unless RYLWEEN_PUBLISH_HOST is set in
-# the shell or in .env; every other setting comes from compose.yaml and .env,
-# both in this directory, which is why it runs compose from here.
-if [ "$MODE" = compose ]; then
- cd "$DEPLOY_DIR"
- if [ -z "${RYLWEEN_PUBLISH_HOST-}" ] && ! grep -qE '^[[:space:]]*RYLWEEN_PUBLISH_HOST=' .env 2>/dev/null; then
- RYLWEEN_PUBLISH_HOST="$(resolve_host)" || {
- echo "Could not find a private LAN IPv4 address on the default route." >&2
- echo "Set RYLWEEN_PUBLISH_HOST=127.0.0.1 or a specific bind address." >&2
- exit 2
- }
- export RYLWEEN_PUBLISH_HOST
- fi
- compose=(docker compose)
- command -v docker >/dev/null 2>&1 || compose=(podman compose)
- "${compose[@]}" up --build -d
-
- # The follow-up commands name the compose file by its full path, so they
- # work from any directory, not only from this one or the repository root.
- printf -v manage '%s -f %q' "${compose[*]}" "$DEPLOY_DIR/compose.yaml"
- address="$("${compose[@]}" port rylween 8081 2>/dev/null)" || address=""
- if [ -z "$address" ]; then
- echo "Compose reports no published port for the rylween service; see its log:" >&2
- echo " $manage logs rylween" >&2
- exit 1
- fi
- if ! wait_for_http "http://$address/api/status"; then
- echo "The server on http://$address/ did not answer within a minute; see its log:" >&2
- echo " $manage logs rylween" >&2
- exit 1
- fi
- echo "Rylween is up on http://$address/"
- echo " Sysop password: $manage exec rylween cat /data/auth/admin-password.txt"
- echo " Server log: $manage logs -f rylween"
- echo " Stop: $manage down"
- exit 0
-fi
-
-# --launcher: run the installed bitmap launcher in the background on the LAN
-# address, with its own data directory, replacing a server it started earlier.
-# Starting it detached hides a missing launcher, so check for it first.
-if [ ! -x "$APP" ]; then
- echo "No installed bitmap launcher at $APP." >&2
- echo "Build it with ./gradlew :runtime-bitmap-web:installRuntimeBitmapWeb first." >&2
- exit 2
-fi
-
-HOST="$(resolve_host)" || {
- echo "Could not find a private LAN IPv4 address on the default route." >&2
- echo "Set RYLWEEN_DEPLOY_HOST=127.0.0.1 or a specific bind address." >&2
- exit 2
-}
-
-stop_existing_server
-
-start_detached "$APP" \
- --host "$HOST" \
- --port "$PORT" \
- --data "$DATA_DIR" \
- --state fresh-replay \
- --map-tiles 6 \
- --tile-size 68
-
-echo "Started bitmap server on http://$HOST:$PORT"
-echo "Log: $LOG_FILE"
diff --git a/deploy/docker/Dockerfile b/deploy/docker/Dockerfile
deleted file mode 100644
index 781ff274..00000000
--- a/deploy/docker/Dockerfile
+++ /dev/null
@@ -1,62 +0,0 @@
-# Self-contained Kotlin web runtime build of Rylween.
-#
-# The Docker image runs the current :runtime-web Kotlin launcher. Older native,
-# Rust, and probe targets are not mature playable products and are not wired
-# into this image.
-#
-# Usage:
-# docker build -f deploy/docker/Dockerfile -t rylween .
-# docker run --rm -p 8080:8080 -v rylween-data:/data rylween
-# ./bin/run-server.sh --build --name Strong
-
-# ---------------------------------------------------------------------
-# Stage 1: builder - compile Kotlin and assemble the web runtime install dir.
-# ---------------------------------------------------------------------
-FROM eclipse-temurin:25-jdk AS builder
-
-WORKDIR /src
-
-COPY gradle/wrapper gradle/wrapper
-# Warm the Gradle wrapper distribution before copying project files that change
-# often. This layer should only be invalidated when the wrapper itself changes.
-COPY gradlew ./
-RUN ./gradlew --no-daemon --version
-
-COPY gradle/libs.versions.toml gradle/libs.versions.toml
-COPY settings.gradle.kts build.gradle.kts ./
-COPY build-logic build-logic
-COPY . .
-# Produces two runtime artifacts, and fails the image build if either the
-# compiled bundle or installed web runtime cannot be built:
-# /src/build/compiled/rylween-bundle.json
-# The compiled game data bundle emitted from the Kotlin DSL.
-# /src/runtimes/runtime-web/build/install/rylween-web/
-# A Gradle install image for the Kotlin web runtime. Its bin/rylween-web
-# file is a generated JVM start script whose main class serves the browser
-# ANSI POC over HTTP/WebSocket; the Kotlin jars and dependencies live beside
-# it under lib/.
-RUN ./gradlew --no-daemon :tools:emitExternalCompiledBundle :runtime-web:installRuntimeWeb --console=plain
-
-# ---------------------------------------------------------------------
-# Stage 2: runtime - JRE plus the Kotlin web runtime install distribution.
-# ---------------------------------------------------------------------
-FROM eclipse-temurin:25-jre AS runtime
-
-ARG RYLWEEN_DATA_DIR=/data
-ENV RYLWEEN_DATA_DIR="${RYLWEEN_DATA_DIR}"
-ENV RYLWEEN_BUNDLE=/app/rylween-bundle.json
-ENV RYLWEEN_HOST=0.0.0.0
-ENV RYLWEEN_PORT=8080
-ENV RYLWEEN_SAVE_FILE=/data/saves/world.rsave
-
-WORKDIR /app
-# Copy the compiled data bundle consumed by the web runtime at startup.
-COPY --from=builder /src/build/compiled/rylween-bundle.json /app/rylween-bundle.json
-# Copy the installed Kotlin web runtime distribution. /app/rylween-web/bin/rylween-web
-# is the generated launcher script, not a native binary or the old ANSI/Rust path.
-COPY --from=builder /src/runtimes/runtime-web/build/install/rylween-web /app/rylween-web
-
-ENV PATH="/app/rylween-web/bin:${PATH}"
-VOLUME ["/data"]
-EXPOSE 8080
-ENTRYPOINT ["sh", "-c", "mkdir -p \"$RYLWEEN_DATA_DIR/saves\" \"$RYLWEEN_DATA_DIR/logs\" \"$RYLWEEN_DATA_DIR/auth\" && exec /app/rylween-web/bin/rylween-web --bundle \"$RYLWEEN_BUNDLE\" --data \"$RYLWEEN_DATA_DIR\" --host \"$RYLWEEN_HOST\" --port \"$RYLWEEN_PORT\" \"$@\"", "rylween-web"]
diff --git a/deploy/docker/Dockerfile.production b/deploy/docker/Dockerfile.ansi
similarity index 65%
rename from deploy/docker/Dockerfile.production
rename to deploy/docker/Dockerfile.ansi
index d31ffd43..1bf4e28c 100644
--- a/deploy/docker/Dockerfile.production
+++ b/deploy/docker/Dockerfile.ansi
@@ -1,19 +1,12 @@
-# Production-oriented ANSI web runtime image for running behind a reverse proxy.
+# The ANSI game for the browser, serving plain HTTP and its WebSocket on port
+# 8080. `./rylween serve --ansi` runs it through deploy/compose.yaml. It marks
+# the login cookie Secure, for HTTPS behind a proxy, unless
+# RYLWEEN_AUTH_SECURE_COOKIES=false; deploy/README.md covers both.
#
-# This image still serves plain HTTP internally. TLS, HSTS, request/body limits,
-# and public internet hardening belong at the reverse proxy or load balancer.
-#
-# Example:
-# docker build -f deploy/docker/Dockerfile.production -t rylween-web-prod .
-# docker run --rm \
-# -e RYLWEEN_AUTH_ACCOUNT=admin \
-# -e RYLWEEN_AUTH_EMAIL=admin@example.test \
-# -e RYLWEEN_AUTH_PASSWORD='change-this-password' \
-# -p 127.0.0.1:8080:8080 \
-# -v rylween-data:/data \
-# rylween-web-prod
-#
-# Point nginx/Caddy/HAProxy at http://127.0.0.1:8080 and terminate HTTPS there.
+# By hand, from the repository root:
+# docker build -f deploy/docker/Dockerfile.ansi -t rylween-ansi .
+# docker run --rm -it -p 127.0.0.1:8080:8080 -v rylween-ansi-data:/data \
+# -e RYLWEEN_AUTH_SECURE_COOKIES=false rylween-ansi
FROM eclipse-temurin:25-jdk AS builder
diff --git a/deploy/docker/Dockerfile.bitmap-production b/deploy/docker/Dockerfile.bitmap
similarity index 78%
rename from deploy/docker/Dockerfile.bitmap-production
rename to deploy/docker/Dockerfile.bitmap
index e1126f6a..5a079ccb 100644
--- a/deploy/docker/Dockerfile.bitmap-production
+++ b/deploy/docker/Dockerfile.bitmap
@@ -1,18 +1,12 @@
-# Production-oriented bitmap web runtime image for running behind a reverse proxy.
+# The bitmap game for the browser, serving plain HTTP and its WebSocket on port
+# 8081. Releases publish it as ghcr.io/lagergren/rylween. `./rylween serve` runs
+# it through deploy/compose.yaml, and deploy/compose.https.yaml puts the released
+# image behind Caddy for HTTPS; deploy/README.md covers both.
#
-# This image serves plain HTTP/WebSocket internally. Terminate TLS at nginx,
-# Caddy, HAProxy, or a managed load balancer, and connect the proxy to this
-# container over loopback or a private network.
-#
-# Example:
-# docker build -f deploy/docker/Dockerfile.bitmap-production -t rylween-bitmap-prod .
-# docker run --rm \
-# -e RYLWEEN_AUTH_ACCOUNT=admin \
-# -e RYLWEEN_AUTH_EMAIL=admin@example.test \
-# -e RYLWEEN_AUTH_PASSWORD='change-this-password' \
-# -p 127.0.0.1:8081:8081 \
-# -v rylween-data:/data \
-# rylween-bitmap-prod
+# By hand, from the repository root:
+# docker build -f deploy/docker/Dockerfile.bitmap -t rylween-bitmap .
+# docker run --rm -it -p 127.0.0.1:8081:8081 -v rylween-data:/data \
+# -e RYLWEEN_AUTH_SECURE_COOKIES=false rylween-bitmap
# The builder runs on the build machine's own platform even when the image is for
# another: Gradle's output is platform-independent jars and JavaScript, so a
diff --git a/deploy/rylween b/deploy/rylween
new file mode 100755
index 00000000..70ef4f8f
--- /dev/null
+++ b/deploy/rylween
@@ -0,0 +1,585 @@
+#!/usr/bin/env bash
+# The one command for running Rylween: play the ANSI game in a terminal, host the
+# game for browsers, stop what it started, and back up its data. It runs from a
+# checkout, where ./rylween in the repository root links to it, and from the
+# terminal game's release download, where it is bin/rylween and only plays.
+# deploy/README.md describes every mode; `rylween help` lists the options.
+set -euo pipefail
+
+# Follow links such as the root ./rylween, so HERE is deploy/ (or the download's bin/).
+script="${BASH_SOURCE[0]}"
+while [[ -L "$script" ]]; do
+ target="$(readlink "$script")"
+ case "$target" in
+ /*) script="$target" ;;
+ *) script="$(dirname "$script")/$target" ;;
+ esac
+done
+HERE="$(cd "$(dirname "$script")" && pwd -P)"
+ROOT="$(dirname "$HERE")"
+
+# The terminal game's release download keeps the runtime's start script and the
+# compiled bundle beside this script; a checkout builds both when needed.
+if [[ -x "$HERE/rylween-runtime" && -f "$ROOT/rylween-bundle.json" ]]; then
+ DISTRIBUTION=true
+ TERMINAL_LAUNCHER="$HERE/rylween-runtime"
+ TERMINAL_BUNDLE="$ROOT/rylween-bundle.json"
+else
+ DISTRIBUTION=false
+ TERMINAL_INSTALL="$ROOT/runtimes/runtime/build/install/rylween"
+ TERMINAL_LAUNCHER="$TERMINAL_INSTALL/bin/rylween"
+ TERMINAL_BUNDLE="$ROOT/build/compiled/rylween-bundle.json"
+fi
+
+DATA_DIR="${RYLWEEN_DATA_DIR:-$HOME/.rylween/data}"
+# Where `serve --no-docker` records the servers it started, for `stop`.
+STATE_DIR="$HOME/.rylween"
+
+usage() {
+ cat <<'EOF'
+Usage: rylween [play] [options] Play the ANSI game in this terminal. The default.
+ rylween serve [options] Host the game for browsers.
+ rylween stop Stop what serve started.
+ rylween backup [options] Archive saves and accounts.
+ rylween help Show this.
+
+play:
+ --name NAME Load a named test party: Strong, or StrongEndgame.
+ --no-title Skip the title screen.
+ --build Rebuild the game first (checkout only).
+ Other options, such as --seed N, --state SLUG, --script KEYS, --debug-log,
+ and --debug-secrets, go to the game. Saves and logs go to ~/.rylween/data
+ (RYLWEEN_DATA_DIR).
+
+serve:
+ --bitmap | --ansi The game: the painted bitmap version (default), or the
+ ANSI version in the browser.
+ --docker | --no-docker
+ Run it in a container (default), or with the launcher
+ built from the checkout, which needs a JDK.
+ --http | --https Plain HTTP (default), or HTTPS behind Caddy for the
+ internet: needs RYLWEEN_DOMAIN, --bitmap, and --docker.
+ --local | --lan | --host ADDRESS
+ Who can connect: this machine only (default), the
+ local network (this machine's LAN address), or the
+ given address.
+ --port PORT Port. Default: 8081 for --bitmap, 8080 for --ansi.
+ --foreground Stay attached, with the server's output; Ctrl-C stops it.
+ --build Rebuild the launcher (--no-docker); containers always
+ build from the checkout.
+ With --no-docker only:
+ --data DIR Data directory. Default: ~/.rylween/data
+ --name NAME Start with a named test party, logged in as it.
+ Other options, such as --debug-secrets, --map-tiles N, --account NAME
+ --password PASSWORD, go to the server. In a container, settings come from
+ deploy/.env instead; see deploy/.env.example.
+
+backup:
+ --data DIR | --volume NAME
+ The data to archive: a directory (default
+ ~/.rylween/data) or a container volume, such as
+ rylween_data for `serve` or rylween-https_data for
+ `serve --https`.
+ --output FILE The archive. Default: rylween-backup-