Merge pull request #13 from MrSleeps/chore/deployment-helper-scripts

Add deployment helper scripts
This commit is contained in:
Sleeps
2026-10-07 11:02:57 +01:00
committed by GitHub
8 changed files with 313 additions and 0 deletions
+55
View File
@@ -83,6 +83,61 @@ If `SCENE_API_KEY` is configured, enter it once in the dashboard. It is stored o
> If an item has no Jellyfin Trickplay data and the indexer must use ffmpeg fallback, its Jellyfin media path must also be mounted into the container at the same path. Trickplay-backed items do not require the original media filesystem to be mounted.
## Deployment helper scripts
Common deployment/admin jobs are wrapped in executable scripts:
```bash
# Build the Jellyfin plugin DLL, install it, fix ownership and restart Jellyfin.
# If dotnet is not installed locally, this automatically builds with the
# official .NET 10 SDK Docker image.
./scripts/plugin-rebuild.sh
# Rebuild/start the Docker stack (Scene Search + Meilisearch).
./scripts/docker-rebuild.sh
# Restart only the Scene Search container without rebuilding it.
./scripts/docker-restart.sh
# Follow the Scene Search container log.
./scripts/logs.sh
# Show Docker, Jellyfin, API health and GPU status.
./scripts/status.sh
# After merging changes: pull, build the DLL, rebuild Docker, deploy the
# plugin, restart Jellyfin and show final status.
./scripts/update-all.sh
```
If you already ran `git pull` yourself:
```bash
./scripts/update-all.sh --no-pull
```
Useful partial update options:
```bash
./scripts/update-all.sh --skip-plugin
./scripts/update-all.sh --skip-docker
# Build the plugin without installing it:
./scripts/plugin-rebuild.sh --build-only
# Install an already-built DLL:
./scripts/plugin-rebuild.sh --install-only
# Install it without restarting Jellyfin:
./scripts/plugin-rebuild.sh --install-only --no-restart
```
The default plugin destination is `/var/lib/jellyfin/plugins/SceneSearch`. Override it when needed:
```bash
JELLYFIN_PLUGIN_DIR=/some/other/path ./scripts/plugin-rebuild.sh
```
## 2. Python environment
Create and activate a venv, install a CUDA-compatible PyTorch build if required, then:
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
set -Eeuo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd -- "${SCRIPT_DIR}/.." && pwd)"
cd "$REPO_ROOT"
PLUGIN_PROJECT="jellyfin-plugin/Jellyfin.Plugin.SceneSearch/Jellyfin.Plugin.SceneSearch.csproj"
PLUGIN_DLL="jellyfin-plugin/Jellyfin.Plugin.SceneSearch/bin/Release/net10.0/Jellyfin.Plugin.SceneSearch.dll"
JELLYFIN_PLUGIN_DIR="${JELLYFIN_PLUGIN_DIR:-/var/lib/jellyfin/plugins/SceneSearch}"
banner() {
printf '\n==> %s\n' "$*"
}
die() {
printf 'ERROR: %s\n' "$*" >&2
exit 1
}
need() {
command -v "$1" >/dev/null 2>&1 || die "Required command not found: $1"
}
as_root() {
if [[ "${EUID}" -eq 0 ]]; then
"$@"
elif command -v sudo >/dev/null 2>&1; then
sudo "$@"
else
die "This step needs root privileges (run as root or install sudo)."
fi
}
compose() {
docker compose "$@"
}
+17
View File
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -Eeuo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/common.sh"
need docker
compose version >/dev/null
banner "Rebuilding and starting Docker services"
if [[ $# -gt 0 ]]; then
compose up -d --build --remove-orphans "$@"
else
compose up -d --build --remove-orphans
fi
banner "Docker status"
compose ps
+16
View File
@@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -Eeuo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/common.sh"
need docker
compose version >/dev/null
if [[ $# -eq 0 ]]; then
set -- scene-search
fi
banner "Restarting Docker service(s): $*"
compose restart "$@"
banner "Docker status"
compose ps "$@"
+11
View File
@@ -0,0 +1,11 @@
#!/usr/bin/env bash
set -Eeuo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/common.sh"
need docker
if [[ $# -eq 0 ]]; then
set -- scene-search
fi
compose logs -f --tail=100 "$@"
+81
View File
@@ -0,0 +1,81 @@
#!/usr/bin/env bash
set -Eeuo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/common.sh"
build_only=false
install_only=false
no_restart=false
while [[ $# -gt 0 ]]; do
case "$1" in
--build-only) build_only=true ;;
--install-only) install_only=true ;;
--no-restart) no_restart=true ;;
-h|--help)
cat <<'EOF'
Usage: ./scripts/plugin-rebuild.sh [options]
Build, install and restart the Jellyfin Scene Search plugin.
Options:
--build-only Build the DLL but do not install/restart Jellyfin.
--install-only Install the already-built DLL without rebuilding it.
--no-restart Install the DLL but do not restart Jellyfin.
JELLYFIN_PLUGIN_DIR may override the default:
/var/lib/jellyfin/plugins/SceneSearch
EOF
exit 0
;;
*) die "Unknown option: $1" ;;
esac
shift
done
if "$build_only" && "$install_only"; then
die "--build-only and --install-only cannot be used together."
fi
build_plugin() {
banner "Building Jellyfin plugin"
if command -v dotnet >/dev/null 2>&1; then
dotnet build "$PLUGIN_PROJECT" -c Release --nologo
else
need docker
banner "dotnet not installed; using mcr.microsoft.com/dotnet/sdk:10.0"
docker run --rm --pull=missing --user "$(id -u):$(id -g)" -e HOME=/tmp -v "$REPO_ROOT:/src" -w /src mcr.microsoft.com/dotnet/sdk:10.0 dotnet build "$PLUGIN_PROJECT" -c Release --nologo
fi
[[ -f "$PLUGIN_DLL" ]] || die "Build finished but DLL was not found: $PLUGIN_DLL"
printf 'Built: %s\n' "$PLUGIN_DLL"
}
install_plugin() {
[[ -f "$PLUGIN_DLL" ]] || die "DLL not found. Run without --install-only first: $PLUGIN_DLL"
banner "Installing Jellyfin plugin"
as_root mkdir -p "$JELLYFIN_PLUGIN_DIR"
as_root install -m 0644 "$PLUGIN_DLL" "$JELLYFIN_PLUGIN_DIR/Jellyfin.Plugin.SceneSearch.dll"
as_root chown -R jellyfin:jellyfin "$JELLYFIN_PLUGIN_DIR"
printf 'Installed: %s\n' "$JELLYFIN_PLUGIN_DIR/Jellyfin.Plugin.SceneSearch.dll"
if ! "$no_restart"; then
banner "Restarting Jellyfin"
as_root systemctl restart jellyfin
if as_root systemctl is-active --quiet jellyfin; then
printf 'Jellyfin is active.\n'
else
die "Jellyfin did not return to active state."
fi
fi
}
if ! "$install_only"; then
build_plugin
fi
if ! "$build_only"; then
install_plugin
fi
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
set -Eeuo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/common.sh"
need docker
banner "Docker"
compose ps || true
banner "Jellyfin"
if command -v systemctl >/dev/null 2>&1; then
systemctl is-active jellyfin || true
else
printf 'systemctl unavailable\n'
fi
banner "Scene Search health"
port="${SCENE_API_PORT:-8097}"
if command -v curl >/dev/null 2>&1; then
health="$(curl -fsS "http://127.0.0.1:${port}/api/health" 2>/dev/null || true)"
if [[ -n "$health" ]]; then
if command -v python3 >/dev/null 2>&1; then
printf '%s' "$health" | python3 -m json.tool || printf '%s\n' "$health"
else
printf '%s\n' "$health"
fi
else
printf 'Scene Search health endpoint unavailable on port %s.\n' "$port"
fi
fi
if command -v nvidia-smi >/dev/null 2>&1; then
banner "GPU"
nvidia-smi --query-gpu=name,memory.used,memory.total,utilization.gpu --format=csv,noheader || true
fi
+61
View File
@@ -0,0 +1,61 @@
#!/usr/bin/env bash
set -Eeuo pipefail
source "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)/common.sh"
no_pull=false
skip_plugin=false
skip_docker=false
while [[ $# -gt 0 ]]; do
case "$1" in
--no-pull) no_pull=true ;;
--skip-plugin) skip_plugin=true ;;
--skip-docker) skip_docker=true ;;
-h|--help)
cat <<'EOF'
Usage: ./scripts/update-all.sh [options]
Update the checkout and deploy Scene Search.
Default sequence:
1. git pull --ff-only
2. build the Jellyfin plugin DLL
3. rebuild/start Docker services
4. install the DLL and restart Jellyfin
5. show status
Options:
--no-pull Skip git pull (useful immediately after you already pulled).
--skip-plugin Do not build/install/restart the Jellyfin plugin.
--skip-docker Do not rebuild/restart Docker.
EOF
exit 0
;;
*) die "Unknown option: $1" ;;
esac
shift
done
if ! "$no_pull"; then
need git
if [[ -n "$(git status --porcelain)" ]]; then
die "Working tree is not clean. Commit/stash local changes, or use --no-pull."
fi
banner "Updating repository"
git pull --ff-only
fi
if ! "$skip_plugin"; then
"$SCRIPT_DIR/plugin-rebuild.sh" --build-only
fi
if ! "$skip_docker"; then
"$SCRIPT_DIR/docker-rebuild.sh"
fi
if ! "$skip_plugin"; then
"$SCRIPT_DIR/plugin-rebuild.sh" --install-only
fi
"$SCRIPT_DIR/status.sh"