2026-05-06 16:16:57 -04:00
|
|
|
#!/bin/sh
|
|
|
|
|
# apply-overlay.sh — Wild Dragon reskin applied to a freshly cloned
|
|
|
|
|
# datarhei/restreamer-ui tree. Two phases:
|
|
|
|
|
#
|
|
|
|
|
# 1. File overlay: cp the contents of $OVERLAY/{public,src} on top of
|
|
|
|
|
# the upstream working tree. Whole-file replacements only — simple
|
|
|
|
|
# and idempotent. Modified views (Edit/index.js, Main/index.js) and
|
|
|
|
|
# all new components (WHEP.js, WHEPStatus.js, Logo/) live here.
|
|
|
|
|
#
|
|
|
|
|
# 2. Targeted awk patches for one-line UI strings that aren't worth a
|
|
|
|
|
# whole-file overlay (the header title, welcome strings). Each
|
|
|
|
|
# pattern is anchored to unique surrounding context so a future
|
|
|
|
|
# upstream rename fails loudly rather than silently no-op'ing.
|
|
|
|
|
#
|
|
|
|
|
# Caller: the Dockerfile ui-builder stage. Expects:
|
|
|
|
|
# $OVERLAY = /overlay (repo overlay/ COPYd into the build)
|
|
|
|
|
# $UI = /ui (cloned upstream source root)
|
|
|
|
|
#
|
|
|
|
|
# Idempotent on a single source tree (re-running is a no-op).
|
|
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
|
|
OVERLAY="${OVERLAY:-/overlay}"
|
|
|
|
|
UI="${UI:-/ui}"
|
|
|
|
|
|
|
|
|
|
echo "wilddragon-overlay: layering $OVERLAY -> $UI"
|
|
|
|
|
|
|
|
|
|
# Phase 1 — file copies. -L follows symlinks, -p preserves perms,
|
|
|
|
|
# -R recursive. --delete is intentionally omitted: the upstream tree
|
|
|
|
|
# stays intact except for the files we override.
|
|
|
|
|
for sub in public src; do
|
|
|
|
|
if [ -d "$OVERLAY/$sub" ]; then
|
2026-05-06 16:19:57 -04:00
|
|
|
cp -RLp "$OVERLAY/$sub/." "$UI/$sub/"
|
2026-05-06 16:16:57 -04:00
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Phase 2 — targeted awk patches. Fails loudly if the needle is missing
|
|
|
|
|
# (upstream changed the patched line).
|
|
|
|
|
patch_line() {
|
|
|
|
|
file="$1"; needle="$2"; replacement="$3"
|
|
|
|
|
if ! grep -qF "$needle" "$file"; then
|
|
|
|
|
echo "wilddragon-overlay: ERROR — pattern not found in $file:"
|
|
|
|
|
echo " $needle"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
tmp="$(mktemp)"
|
|
|
|
|
awk -v n="$needle" -v r="$replacement" '
|
|
|
|
|
index($0, n) { sub(n, r); }
|
|
|
|
|
{ print }
|
|
|
|
|
' "$file" > "$tmp"
|
|
|
|
|
mv "$tmp" "$file"
|
|
|
|
|
echo "wilddragon-overlay: patched $(basename "$file") — $needle -> $replacement"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
patch_line "$UI/src/Header.js" \
|
|
|
|
|
'<Typography className="headerTitle">Restreamer</Typography>' \
|
|
|
|
|
'<Typography className="headerTitle">Wild Dragon</Typography>'
|
|
|
|
|
|
|
|
|
|
patch_line "$UI/src/views/Welcome.js" \
|
|
|
|
|
'title="Welcome to Restreamer v2"' \
|
|
|
|
|
'title="Welcome to Wild Dragon"'
|
|
|
|
|
|
|
|
|
|
patch_line "$UI/src/views/Settings.js" \
|
|
|
|
|
'title="Welcome to Restreamer v2"' \
|
|
|
|
|
'title="Welcome to Wild Dragon"'
|
|
|
|
|
|
|
|
|
|
echo "wilddragon-overlay: done."
|