#!/bin/bash # Einfaches Fix-Skript für i18n-Daten set -e echo "🔧 Fixe i18n-Daten..." echo "" # Prüfe ob Container läuft if ! docker ps | grep -q hoerdle; then echo "❌ Container 'hoerdle' läuft nicht!" exit 1 fi # Backup BACKUP_FILE="./data/prod.db.backup.$(date +%Y%m%d_%H%M%S)" echo "💾 Erstelle Backup..." docker cp hoerdle:/app/data/prod.db "$BACKUP_FILE" || { echo "❌ Backup fehlgeschlagen!" exit 1 } echo "✅ Backup: $BACKUP_FILE" echo "" # Kopiere DB echo "📥 Kopiere Datenbank lokal..." DB_TMP="./data/prod.db.tmp" docker cp hoerdle:/app/data/prod.db "$DB_TMP" echo "✅ Datenbank kopiert" echo "" # Setze Berechtigungen echo "🔐 Setze Berechtigungen..." sudo chmod 666 "$DB_TMP" 2>/dev/null || chmod 666 "$DB_TMP" || { echo "⚠️ Konnte Berechtigungen nicht setzen" } sudo chmod 775 ./data 2>/dev/null || chmod 775 ./data || true echo "" # Prüfe sqlite3 if ! command -v sqlite3 &> /dev/null; then echo "❌ sqlite3 nicht gefunden! Installiere es:" echo " sudo apt-get update && sudo apt-get install -y sqlite3" exit 1 fi # Fixe DB echo "🔧 Führe SQL-Updates aus..." sqlite3 "$DB_TMP" << 'SQL' || { echo "⚠️ Normale Ausführung fehlgeschlagen, versuche mit sudo..." sudo sqlite3 "$DB_TMP" << 'SQL2' UPDATE Genre SET name = json_object('de', name, 'en', name) WHERE typeof(name) = 'text' AND name NOT LIKE '{%'; UPDATE Genre SET subtitle = json_object('de', subtitle, 'en', subtitle) WHERE subtitle IS NOT NULL AND typeof(subtitle) = 'text' AND subtitle NOT LIKE '{%'; UPDATE Special SET name = json_object('de', name, 'en', name) WHERE typeof(name) = 'text' AND name NOT LIKE '{%'; UPDATE Special SET subtitle = json_object('de', subtitle, 'en', subtitle) WHERE subtitle IS NOT NULL AND typeof(subtitle) = 'text' AND subtitle NOT LIKE '{%'; UPDATE News SET title = json_object('de', title, 'en', title) WHERE typeof(title) = 'text' AND title NOT LIKE '{%'; UPDATE News SET content = json_object('de', content, 'en', content) WHERE typeof(content) = 'text' AND content NOT LIKE '{%'; SQL2 } UPDATE Genre SET name = json_object('de', name, 'en', name) WHERE typeof(name) = 'text' AND name NOT LIKE '{%'; UPDATE Genre SET subtitle = json_object('de', subtitle, 'en', subtitle) WHERE subtitle IS NOT NULL AND typeof(subtitle) = 'text' AND subtitle NOT LIKE '{%'; UPDATE Special SET name = json_object('de', name, 'en', name) WHERE typeof(name) = 'text' AND name NOT LIKE '{%'; UPDATE Special SET subtitle = json_object('de', subtitle, 'en', subtitle) WHERE subtitle IS NOT NULL AND typeof(subtitle) = 'text' AND subtitle NOT LIKE '{%'; UPDATE News SET title = json_object('de', title, 'en', title) WHERE typeof(title) = 'text' AND title NOT LIKE '{%'; UPDATE News SET content = json_object('de', content, 'en', content) WHERE typeof(content) = 'text' AND content NOT LIKE '{%'; SELECT '✅ Fertig!' as status; SQL echo "" echo "✅ Datenbank gefixt" echo "" # Kopiere zurück echo "📤 Kopiere Datenbank zurück..." docker cp "$DB_TMP" hoerdle:/app/data/prod.db echo "✅ Zurück kopiert" echo "" # Aufräumen rm -f "$DB_TMP" echo "🔄 Starte Container neu..." docker compose restart hoerdle echo "" echo "✅ Fertig! Prüfe Logs: docker logs hoerdle --tail=50"