datarhei-dragonfork-core/deploy/truenas/core/seed-data.sh

38 lines
1.1 KiB
Bash
Raw Normal View History

#!/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
# Iterate over both files and directories. The Restreamer UI bundle
# ships subdirectories (_player, _playersite, static) so this needs
# the recursive flag; the no-clobber check on the top-level name keeps
# operator-edited content safe.
for f in "$SRC"/* "$SRC"/.[!.]*; do
[ -e "$f" ] || continue
name=$(basename "$f")
if [ ! -e "$DST/$name" ]; then
cp -Rp "$f" "$DST/$name"
echo "seed-data: copied $name -> $DST/$name"
fi
done