Files
Paul HittandClaude Opus 5 51abf2cf26 FlameNet Classic: a 90s set-top skin for Jellyfin 10.11
CSS theme that restyles Jellyfin as a 1999-era DVR: gold selection bar,
chunky bevels, a proper grid channel guide, CRT phosphor.

Selectors were read out of a live 10.11.11 server's own shipped bundles
rather than from memory. Includes an offline preview harness that uses
Jellyfin's real DOM structure, an optional Web Audio + guide-NOW-line
extras layer, and install/rollback scripts.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-07 10:37:39 -04:00

176 lines
6.8 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# FlameNet Classic — installer for the OPTIONAL extras layer (flamenet-extras.js)
#
# The CSS theme does NOT need this. flamenet.css goes in Dashboard -> General ->
# Custom CSS and is entirely reversible from the UI. This script exists only for
# the JS extras (navigation sounds + the guide NOW line), because Jellyfin has no
# supported hook for custom JavaScript — the only way in is a <script> tag in
# index.html.
#
# ./install-extras.sh --dry-run show exactly what would change
# ./install-extras.sh --install
# ./install-extras.sh --uninstall
# ./install-extras.sh --status
#
# --container NAME docker container (default: jellyfin)
# --host USER@HOST run over ssh (default: local docker)
#
# ---------------------------------------------------------------------------
# READ THIS FIRST
#
# 1. This edits index.html INSIDE the running container. Container filesystems
# are ephemeral: `docker compose pull && up -d` recreates the container and
# your change is GONE. That is not a bug in this script, it is how containers
# work. Re-run --install after every image update. --status tells you whether
# it is currently present.
#
# 2. It is deliberately NOT a bind-mount. Bind-mounting index.html would survive
# updates but would also PIN a stale index.html over a newer web client, which
# breaks the app in confusing ways the next time Jellyfin's bundle names change.
# Re-running a script is the lesser evil.
#
# 3. A backup is written next to the original as index.html.flamenet-bak before
# the first edit. --uninstall restores from it.
#
# 4. UNTESTED against a live server. It was written against, but never run on,
# jellyfin.example.com. Use --dry-run first and read the diff.
# ---------------------------------------------------------------------------
set -euo pipefail
CONTAINER="jellyfin"
SSH_HOST=""
MODE=""
MARK_BEGIN="<!-- flamenet-extras:begin -->"
MARK_END="<!-- flamenet-extras:end -->"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
JS_SRC="$SCRIPT_DIR/flamenet-extras.js"
while [[ $# -gt 0 ]]; do
case "$1" in
--install|--uninstall|--status|--dry-run) MODE="${1#--}"; shift ;;
--container) CONTAINER="$2"; shift 2 ;;
--host) SSH_HOST="$2"; shift 2 ;;
-h|--help) sed -n '2,40p' "$0"; exit 0 ;;
*) echo "unknown argument: $1" >&2; exit 2 ;;
esac
done
if [[ -z "$MODE" ]]; then
echo "nothing to do — pass --dry-run, --install, --uninstall or --status" >&2
exit 2
fi
# run a command either locally or on the remote docker host
run() {
if [[ -n "$SSH_HOST" ]]; then ssh "$SSH_HOST" "$@"; else bash -c "$*"; fi
}
dexec() { run "docker exec $CONTAINER sh -c '$1'"; }
say() { printf '%s\n' "$*"; }
die() { printf 'error: %s\n' "$*" >&2; exit 1; }
# --- locate the web root -----------------------------------------------------
# Do not hardcode: it differs between the official image, the linuxserver image
# and a native install. Find the directory that actually contains index.html
# alongside the client bundle.
say "==> locating Jellyfin web root in container '$CONTAINER'"
WEBROOT="$(dexec 'for d in /usr/share/jellyfin/web /usr/lib/jellyfin/bin/jellyfin-web /jellyfin/jellyfin-web /app/jellyfin/jellyfin-web; do [ -f "$d/index.html" ] && echo "$d" && break; done' || true)"
if [[ -z "$WEBROOT" ]]; then
say " common paths missed — searching (this can take a moment)"
WEBROOT="$(dexec 'dirname "$(find / -name index.html -path "*web*" -maxdepth 6 2>/dev/null | head -1)"' || true)"
fi
[[ -n "$WEBROOT" && "$WEBROOT" != "." ]] || die "could not find the web root. Is the container named '$CONTAINER' and running?"
say " web root: $WEBROOT"
INDEX="$WEBROOT/index.html"
BAK="$WEBROOT/index.html.flamenet-bak"
is_installed() {
dexec "grep -q 'flamenet-extras:begin' '$INDEX'" >/dev/null 2>&1
}
case "$MODE" in
status)
if is_installed; then
say "==> INSTALLED — flamenet-extras.js is injected into $INDEX"
dexec "ls -la '$WEBROOT/flamenet-extras.js'" || say " WARNING: script tag present but the JS file is missing"
else
say "==> NOT installed (index.html has no flamenet-extras marker)"
say " if you installed it before, an image update has since replaced the container"
fi
;;
dry-run)
[[ -f "$JS_SRC" ]] || die "flamenet-extras.js not found next to this script"
say ""
say "would copy : $JS_SRC"
say " -> $CONTAINER:$WEBROOT/flamenet-extras.js ($(wc -c < "$JS_SRC" | tr -d ' ') bytes)"
say ""
say "would back up $INDEX -> $BAK"
say ""
say "would insert immediately before </body> in $INDEX:"
say " $MARK_BEGIN"
say " <script defer src=\"flamenet-extras.js\"></script>"
say " $MARK_END"
say ""
if is_installed; then
say "NOTE: already installed — --install would replace the existing block, not duplicate it."
fi
say "current </body> context:"
dexec "grep -n -B2 '</body>' '$INDEX' | tail -8" || true
;;
install)
[[ -f "$JS_SRC" ]] || die "flamenet-extras.js not found next to this script"
# remove any previous block first so repeat runs never stack up
if is_installed; then
say "==> existing install found — removing it before reinstalling"
dexec "sed -i '/flamenet-extras:begin/,/flamenet-extras:end/d' '$INDEX'"
else
say "==> backing up index.html"
dexec "[ -f '$BAK' ] || cp '$INDEX' '$BAK'"
fi
say "==> copying flamenet-extras.js into the container"
if [[ -n "$SSH_HOST" ]]; then
# stage on the remote host, then into the container
scp -q "$JS_SRC" "$SSH_HOST:/tmp/flamenet-extras.js"
run "docker cp /tmp/flamenet-extras.js $CONTAINER:$WEBROOT/flamenet-extras.js && rm -f /tmp/flamenet-extras.js"
else
docker cp "$JS_SRC" "$CONTAINER:$WEBROOT/flamenet-extras.js"
fi
say "==> injecting the script tag"
dexec "sed -i 's#</body>#$MARK_BEGIN\n<script defer src=\"flamenet-extras.js\"></script>\n$MARK_END\n</body>#' '$INDEX'"
if is_installed; then
say ""
say "==> done. Hard-reload the client (Cmd/Ctrl+Shift+R)."
say " Console check: FlameNet.status()"
say " Mute sounds: FlameNet.sound(false)"
say ""
say " REMINDER: this lives inside the container. Re-run after any image update."
else
die "injection did not take — index.html may have no </body> tag. Restore with --uninstall."
fi
;;
uninstall)
if dexec "[ -f '$BAK' ]"; then
say "==> restoring index.html from backup"
dexec "cp '$BAK' '$INDEX'"
else
say "==> no backup found; stripping the injected block instead"
dexec "sed -i '/flamenet-extras:begin/,/flamenet-extras:end/d' '$INDEX'"
fi
dexec "rm -f '$WEBROOT/flamenet-extras.js'" || true
say "==> removed. Hard-reload the client."
say " (The CSS theme is unaffected — clear the Custom CSS box to remove that.)"
;;
esac