#!/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
