Update Jellyfin_Fix_and_Scan.sh

added 2nd option to test the DB instead of reading logs
This commit is contained in:
Clarth 2025-04-14 18:43:32 -04:00
parent f2105d6f4f
commit 93a6779b17

View file

@ -43,6 +43,38 @@ else
echo "No error found in journal."
fi
greenecho "Double checking the DB integrity"
# Run the SQLite integrity check and capture the output
output=$(sudo sqlite3 /var/lib/jellyfin/data/library.db "PRAGMA integrity_check;")
# Check if the output indicates that the database is OK
if [[ "$output" != "ok" ]]; then
echo "Database integrity check failed: $output"
# Stop Jellyfin
sudo systemctl stop jellyfin
yellowecho "Waiting 60 seconds for jellyfin to stop"
sleep 60
# Remove bad DB
rm -f /var/lib/jellyfin/data/library.db
rm -f /var/lib/jellyfin/data/library.db*
# Replace bad DB
cp "/path/to/backups/Jellyfin/library.db.master" "/var/lib/jellyfin/data/library.db"
# Fix Permissions
/usr/bin/chown jellyfin:jellyfin "/var/lib/jellyfin/data/library.db"
/usr/bin/chmod 600 "/var/lib/jellyfin/data/library.db"
greenecho "Database file replaced with backup."
greenecho "Starting Jellyfin."
yellowecho "Waiting 60 seconds so JF can start."
# Start Jellyfin
sudo systemctl start jellyfin
sleep 60
else
greenecho "Database integrity is OK."
fi
#Even if no DB curruption, update the live TV, why not?
# Trigger Live TV / M3U scan