Files
feedc0de 4127b8429b
Validate and deploy Jellyfin / Validate manifests and scripts (push) Successful in 12s
Validate and deploy Jellyfin / Deploy to Kubernetes (push) Successful in 18s
Initial commit with the existing deployment files
2026-10-09 09:14:10 +02:00

48 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
project_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)
expected_context=kubernetes-admin@kubernetes
context=$(kubectl config current-context)
if [[ "${context}" != "${expected_context}" ]]; then
echo "Expected Kubernetes context ${expected_context}, found ${context}." >&2
exit 1
fi
sudo systemctl stop jellyfin.service
if sudo systemctl is-active --quiet jellyfin.service; then
echo 'jellyfin.service is still active; refusing to copy its databases.' >&2
exit 1
fi
if pgrep -u jellyfin >/dev/null; then
echo 'A process owned by jellyfin is still running; refusing to copy its databases.' >&2
exit 1
fi
while IFS= read -r -d '' database; do
result=$(sudo -u jellyfin sqlite3 "${database}" 'PRAGMA quick_check;')
if [[ "${result}" != ok ]]; then
echo "SQLite quick_check failed for ${database}: ${result}" >&2
exit 1
fi
done < <(sudo -u jellyfin find /var/lib/jellyfin -type f -name '*.db' -print0)
kubectl apply --filename "${project_dir}/namespace.yaml"
kubectl apply --filename "${project_dir}/jellyfin.yaml" \
--selector=app.kubernetes.io/component=state
kubectl --namespace jellyfin wait \
--for=jsonpath='{.status.phase}'=Bound \
persistentvolumeclaim/jellyfin-config \
--timeout=10m
if kubectl --namespace jellyfin get job jellyfin-archlinux-migration >/dev/null 2>&1; then
echo 'Job jellyfin-archlinux-migration already exists; inspect it instead of overwriting it.' >&2
exit 1
fi
kubectl apply --filename "${project_dir}/migration-job.yaml"
echo 'Migration started. Follow it with:'
echo ' kubectl -n jellyfin logs -f job/jellyfin-archlinux-migration'
echo ' kubectl -n jellyfin wait --for=condition=complete job/jellyfin-archlinux-migration --timeout=12h'