Ship the plugin sources, release zip, and SeerrFin-style manifest.json so Jellyfin can install from the Gitea raw repository URL. Co-authored-by: Cursor <cursoragent@cursor.com>
76 lines
1.8 KiB
Bash
76 lines
1.8 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
loader_src="/Requests/Assets/nav-loader.js"
|
|
marker_start="<!-- jellyfin-plugin-request-nav-start -->"
|
|
marker_end="<!-- jellyfin-plugin-request-nav-end -->"
|
|
|
|
usage() {
|
|
cat <<EOF
|
|
Usage: sudo bash scripts/install-web-loader.sh [path-to-index.html]
|
|
|
|
Injects the Request nav loader into jellyfin-web index.html.
|
|
EOF
|
|
}
|
|
|
|
index_path="${1:-}"
|
|
if [ -z "$index_path" ]; then
|
|
for candidate in \
|
|
/usr/share/jellyfin/web/index.html \
|
|
/usr/lib/jellyfin/bin/jellyfin-web/index.html \
|
|
/config/jellyfin-web/index.html
|
|
do
|
|
if [ -f "$candidate" ]; then
|
|
index_path="$candidate"
|
|
break
|
|
fi
|
|
done
|
|
fi
|
|
|
|
if [ -z "$index_path" ] || [ ! -f "$index_path" ]; then
|
|
echo "Could not find jellyfin-web index.html." >&2
|
|
usage
|
|
echo "Pass the path explicitly, for example:" >&2
|
|
echo " sudo bash scripts/install-web-loader.sh /usr/share/jellyfin/web/index.html" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -w "$index_path" ]; then
|
|
echo "Cannot write to $index_path. Run this script with sudo or fix permissions." >&2
|
|
exit 1
|
|
fi
|
|
|
|
if grep -Fq "$loader_src" "$index_path"; then
|
|
echo "Request web loader is already installed in $index_path"
|
|
exit 0
|
|
fi
|
|
|
|
backup_path="${index_path}.bak.request.$(date -u +%Y%m%d%H%M%S)"
|
|
cp -p "$index_path" "$backup_path"
|
|
|
|
tmp_path="$(mktemp)"
|
|
block="${marker_start}
|
|
<script src=\"${loader_src}\" defer></script>
|
|
${marker_end}"
|
|
|
|
awk -v block="$block" '
|
|
BEGIN { inserted = 0 }
|
|
/<\/body>/ && inserted == 0 {
|
|
print block
|
|
inserted = 1
|
|
}
|
|
{ print }
|
|
END {
|
|
if (inserted == 0) {
|
|
print block
|
|
}
|
|
}
|
|
' "$index_path" > "$tmp_path"
|
|
|
|
cat "$tmp_path" > "$index_path"
|
|
rm -f "$tmp_path"
|
|
|
|
echo "Installed Request web loader in $index_path"
|
|
echo "Backup saved to $backup_path"
|
|
echo "Restart Jellyfin, then hard refresh the browser."
|