panel v0.9.1 — open-source game server manager

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-14 23:18:05 -07:00
commit 4cf3471398
2161 changed files with 300831 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
# panel-native Terraria runtime image.
FROM debian:12-slim
ENV DEBIAN_FRONTEND=noninteractive \
TZ=Etc/UTC \
LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
locales \
tini \
unzip \
&& sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
&& locale-gen \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN groupadd -g 1000 panel \
&& useradd -u 1000 -g 1000 -m -s /bin/bash panel \
&& mkdir -p /game /game-saves \
&& chown -R panel:panel /game /game-saves
COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh
EXPOSE 7777/tcp
ENTRYPOINT ["/usr/bin/tini", "--", "/entrypoint.sh"]
+69
View File
@@ -0,0 +1,69 @@
#!/bin/bash
# panel-native Terraria entrypoint.
set -euo pipefail
log() { printf '[panel-terraria] %s\n' "$*"; }
if [[ "$(id -u)" = "0" ]]; then
chown -R panel:panel /game /game-saves /home/panel 2>/dev/null || true
exec setpriv --reuid=panel --regid=panel --clear-groups \
--inh-caps=-all --bounding-set=-all \
env HOME=/game-saves PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
WORLD_NAME="${WORLD_NAME:-DedicatedWorld}" \
WORLD_SIZE="${WORLD_SIZE:-2}" \
MAX_PLAYERS="${MAX_PLAYERS:-8}" \
SERVER_PASSWORD="${SERVER_PASSWORD:-}" \
GAME_PORT="${GAME_PORT:-7777}" \
/entrypoint.sh "$@"
fi
GAME_DIR=/game
SAVE_DIR=/game-saves
# The panel's direct update provider drops the raw zip at
# /game-saves/terraria-server.zip (it does not extract archives).
# Unpack it into /game on boot, then delete the zip.
ZIP="${SAVE_DIR}/terraria-server.zip"
if [[ -s "${ZIP}" ]]; then
log "extracting $(basename "${ZIP}") into ${GAME_DIR}"
unzip -o -q "${ZIP}" -d "${GAME_DIR}"
rm -f "${ZIP}"
fi
# Terraria's zip extracts into /game/<version>/{Linux,Mac,Windows}. Find
# the Linux dir regardless of version folder name.
LINUX_DIR=$(find "${GAME_DIR}" -maxdepth 3 -type d -name Linux 2>/dev/null | head -n1 || true)
if [[ -z "${LINUX_DIR}" ]]; then
log "ERROR: Terraria Linux server binary not found under /game."
log " Run 'Update' in the panel to download Terraria headless server."
exit 78
fi
EXE="${LINUX_DIR}/TerrariaServer.bin.x86_64"
[[ -x "${EXE}" ]] || chmod +x "${EXE}" 2>/dev/null || true
# Terraria reads serverconfig.txt if -config is passed. Seed a minimal one
# with our env vars so the server starts without interactive prompts.
CONFIG="${SAVE_DIR}/serverconfig.txt"
if [[ ! -s "${CONFIG}" ]]; then
log "seeding ${CONFIG}"
{
echo "world=${SAVE_DIR}/Worlds/${WORLD_NAME}.wld"
echo "worldname=${WORLD_NAME}"
echo "autocreate=${WORLD_SIZE}"
echo "maxplayers=${MAX_PLAYERS}"
echo "port=${GAME_PORT:-7777}"
echo "motd=Running on panel"
echo "difficulty=1"
[[ -n "${SERVER_PASSWORD}" ]] && echo "password=${SERVER_PASSWORD}" || true
} > "${CONFIG}"
fi
mkdir -p "${SAVE_DIR}/Worlds"
cd "${LINUX_DIR}"
log "starting Terraria dedicated server"
log " world: ${WORLD_NAME} (size ${WORLD_SIZE})"
log " config: ${CONFIG}"
log " port: ${GAME_PORT:-7777}"
# -port on the command line overrides serverconfig.txt, so a panel port
# change takes effect even when a stale config was seeded on a prior boot.
exec stdbuf -oL -eL "${EXE}" -config "${CONFIG}" -port "${GAME_PORT:-7777}"
+104
View File
@@ -0,0 +1,104 @@
# Terraria — panel-native dedicated server module.
#
# Uses direct download from terraria.org (headless zip). Vanilla Terraria
# has no RCON — admin console is stdin. Ships without RCON/Players tab
# for v1 (same story as Empyrion / Barotrauma). Users running the
# tShock fork add Source RCON and can switch adapters later.
#
# Reference: https://github.com/CubeCoders/AMPTemplates (Terraria.kvp)
id: terraria
name: "Terraria"
version: 0.1.0
authors:
- panel contributors
supported_modes:
- docker
runtime:
docker:
image: panel-terraria:latest
# Host networking -- container shares the host net namespace, so
# any port the game/mod binds is directly on the LAN. AMP-like
# model. Multi-instance safety comes from env-driven per-instance
# ports (panel allocator + env: mapping on each ports entry).
network_mode: host
browseable_root: /game-saves
browseable_roots:
- name: "Saves & Configs"
path: /game-saves
hint: "Worlds/, serverconfig.txt"
- name: "Game Files"
path: /game
hint: "Terraria binaries"
env:
WORLD_NAME: "DedicatedWorld"
WORLD_SIZE: "2" # 1=small, 2=medium, 3=large
MAX_PLAYERS: "8"
SERVER_PASSWORD: ""
# Pre-declared so the agent's resolve.go filter lets the panel-allocated
# port flow through to the container env. The entrypoint passes it as
# -port (and seeds serverconfig.txt); without it the server binds the
# hardcoded 7777 and ignores the panel allocation. Default matches the
# port default.
GAME_PORT: "7777"
volumes:
- { type: volume, name: "panel-$INSTANCE_ID-saves", container: "/game-saves" }
- { type: volume, name: "panel-$INSTANCE_ID-game", container: "/game" }
- { target: "$DATA_PATH/logs", container: "/game-saves/logs" }
ports:
- { name: game, proto: tcp, default: 7777, required: true, env: GAME_PORT }
resources:
min_ram_mb: 1024
recommended_ram_mb: 2048
rcon:
# Vanilla Terraria admin is stdin-only. Commands like "say", "save",
# "exit" go straight to the server process.
adapter: stdio
commands:
save: "save"
say: "say {msg}"
kick: "kick {player}"
shutdown: "exit"
# Log-derived player events. Regexes converted from CubeCoders'
# AMPTemplates (terraria.kvp) — .NET (?<n>) syntax -> Go (?P<n>).
# Sourced-from-template; not yet exercised against a live client.
events:
join:
pattern: '^(?P<name>.+?) has joined\.$'
kind: join
leave:
pattern: '^(?P<name>.+?) has left\.$'
kind: leave
chat:
pattern: '^<(?P<name>.+?)> (?P<msg>.+)$'
kind: chat
update_providers:
# Terraria ships headless Linux server as a versioned zip from terraria.org.
# AMP hard-codes the latest-known URL; we take the same approach. Bump when
# Re-Logic cuts a new version. NOTE: the direct provider does NOT extract —
# it writes the raw bytes to BrowseableRoot+target_path (so this lands at
# /game-saves/terraria-server.zip). The entrypoint unzips it into /game on
# the next boot and deletes the zip.
- id: stable
kind: direct
url: "https://terraria.org/api/download/pc-dedicated-server/terraria-server-1449.zip"
target_path: /terraria-server.zip
# --- Manifest-driven UI metadata (WI-07) --------------------------
# Consumed by the CONTROLLER/dashboard only (the controller loads its
# own ./modules copy at startup); the agent ignores these at runtime.
# ready_pattern is a JavaScript regex (slash-delimited when it needs
# flags) moved verbatim from the dashboard's READY_PATTERNS map.
ready_pattern: '/Server started|Listening on port \d+/i'
appearance:
emoji: "🌳"
grad: "linear-gradient(135deg,#2d7141,#78c87a)"
art: "/game-art/terraria.jpg"
steam: "105600"