initial commit 2

This commit is contained in:
2026-04-02 18:33:07 -07:00
parent fcf67bee82
commit 5883a664d0
3 changed files with 181 additions and 0 deletions

51
inject-banner.sh Executable file
View File

@@ -0,0 +1,51 @@
#!/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'<script id="custom-banner-script">.*?</script>', '', html, flags=re.DOTALL)
# Inject before </body>
tag = f'<script id="custom-banner-script">{js}</script>'
html = html.replace('</body>', tag + '</body>', 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