#!/bin/bash set -euo pipefail CUSTOM_DIR="/srv/jellyfin/custom" WEB_DIR="/usr/share/jellyfin/web" SRC_JS="${CUSTOM_DIR}/banner.js" INDEX="${WEB_DIR}/index.html" if [[ ! -f "${SRC_JS}" ]]; then echo "jellyfin-inject-banner: ${SRC_JS} not found, skipping." >&2 exit 0 fi python3 - "${INDEX}" "${SRC_JS}" <<'EOF' import sys index_path, js_path = sys.argv[1], sys.argv[2] with open(index_path, 'r') as f: html = f.read() with open(js_path, 'r') as f: js = f.read() # Remove any previous injection import re html = re.sub(r'', '', html, flags=re.DOTALL) # Inject before tag = f'' html = html.replace('', tag + '', 1) with open(index_path, 'w') as f: f.write(html) print("jellyfin-inject-banner: inlined banner script into " + index_path) EOF # Replace the logo image (filename contains a content hash that changes on updates) LOGO_SRC="${CUSTOM_DIR}/banner-light.png" if [[ -f "${LOGO_SRC}" ]]; then LOGO_DEST=$(ls "${WEB_DIR}"/banner-light.*.png 2>/dev/null | head -1) if [[ -n "${LOGO_DEST}" ]]; then cp "${LOGO_SRC}" "${LOGO_DEST}" echo "jellyfin-inject-banner: replaced logo at ${LOGO_DEST}" else echo "jellyfin-inject-banner: no banner-light.*.png found in ${WEB_DIR}, skipping logo." >&2 fi else echo "jellyfin-inject-banner: ${LOGO_SRC} not found, skipping logo." >&2 fi