datarhei-dragonfork-core/deploy/truenas/core/seed-data.sh
Zac Gaetano 45f39a9132
Some checks failed
ci / vet + build (push) Successful in 9m49s
ci / race tests (push) Failing after 8m1s
ci / WebRTC smoke (5-viewer fanout) (push) Successful in 9m46s
ci / WebRTC latency p95 gate (push) Successful in 10m5s
deploy: ship a Dragon Fork landing page at / (fixes root 404)
A clean post-merge deploy showed an unintended UX wart: hitting
http://<host>:<port>/ in a browser returned 404 'File not found'
because Core's static-disk handler serves /core/data and we never
put anything there. Functionally fine — the API and Swagger are
reachable on /api and /api/swagger — but a confusing first
impression for a brand-new operator.

Fix is deploy-side, not code-side: ship a small landing page +
the existing test/whep-player.html as default content for the data
volume.

Pieces:
  deploy/truenas/core/static/
    index.html         — Dragon Fork-branded landing page; links
                         to Swagger and the WHEP player; live
                         /api status panel.
    whep-player.html   — same self-contained Pion subscriber that
                         lives at test/whep-player.html.
  deploy/truenas/core/seed-data.sh
    First-boot script. Copies /core/static/* into /core/data/
    only when the destination filename doesn't already exist —
    operator-supplied content is never clobbered, so this is a
    safe addition that respects upstream's contract that
    /core/data is operator-owned.
  deploy/truenas/core/Dockerfile
    COPYs the static dir and seed script into the runtime image,
    wraps the entrypoint as 'seed-data.sh && exec run.sh' (run.sh
    itself is unchanged from upstream).

Image size impact: ~15KB.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-03 12:44:04 +00:00

33 lines
897 B
Bash
Executable file

#!/bin/sh
# seed-data.sh — first-boot seed of /core/data with Dragon Fork
# landing page artifacts (index.html, whep-player.html).
#
# Runs from the entrypoint before bin/core. Skips itself if any of the
# target files already exist, so user-supplied content (or content from
# a previous deploy that they edited) is never clobbered.
#
# Source dir: /core/static (baked by the Dockerfile)
# Target dir: /core/data (operator-mounted; what Core serves at /)
set -e
SRC=/core/static
DST="${CORE_STORAGE_DISK_DIR:-/core/data}"
if [ ! -d "$SRC" ]; then
# No static dir baked — nothing to seed. Fall through silently.
exit 0
fi
if [ ! -d "$DST" ]; then
mkdir -p "$DST"
fi
for f in "$SRC"/*; do
[ -e "$f" ] || continue
name=$(basename "$f")
if [ ! -e "$DST/$name" ]; then
cp -p "$f" "$DST/$name"
echo "seed-data: copied $name -> $DST/$name"
fi
done