#!/bin/sh
set -e

SEED_MARKER="/app/public/images/.seeded"
SEED_SRC="/app/seed/images"
DEST="/app/public/images"

if [ ! -f "$SEED_MARKER" ]; then
  echo "First run — seeding existing uploads..."
  if [ -d "$SEED_SRC" ]; then
    cp -r "$SEED_SRC"/* "$DEST/"
    echo "Seed complete."
  else
    echo "No seed directory found — skipping."
  fi
  touch "$SEED_MARKER"
else
  echo "Uploads already seeded — skipping."
fi

exec "$@"
