Fix repair.sh: Use python:3.11-slim image instead of bridge image
This commit is contained in:
34
repair.sh
34
repair.sh
@@ -1,20 +1,22 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
echo "=== Beeper Bridge Repair Tool v2 (Python YAML Fix) ==="
|
echo "=== Beeper Bridge Repair Tool v3 (Python Fix) ==="
|
||||||
|
|
||||||
# 1. Python Script erstellen, das YAML sauber manipuliert
|
# 1. Python Script erstellen
|
||||||
cat << 'PYTHON_SCRIPT' > fix_yaml.py
|
cat << 'PYTHON_SCRIPT' > fix_yaml.py
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# Versuche ruamel.yaml zu importieren (Standard in mautrix images), sonst pyyaml
|
# Pip install on the fly if needed (wird im Container gemacht)
|
||||||
try:
|
try:
|
||||||
from ruamel.yaml import YAML
|
from ruamel.yaml import YAML
|
||||||
yaml = YAML()
|
|
||||||
yaml.preserve_quotes = True
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("WARNUNG: ruamel.yaml nicht gefunden. Nutze einfaches String-Parsing (weniger sicher).")
|
import subprocess
|
||||||
sys.exit(1)
|
subprocess.check_call([sys.executable, "-m", "pip", "install", "ruamel.yaml"])
|
||||||
|
from ruamel.yaml import YAML
|
||||||
|
|
||||||
|
yaml = YAML()
|
||||||
|
yaml.preserve_quotes = True
|
||||||
|
|
||||||
files = [
|
files = [
|
||||||
"data/whatsapp/config.yaml",
|
"data/whatsapp/config.yaml",
|
||||||
@@ -58,18 +60,14 @@ for file_path in files:
|
|||||||
|
|
||||||
# 1. Fix Database URI
|
# 1. Fix Database URI
|
||||||
if 'appservice' in data and 'database' in data['appservice']:
|
if 'appservice' in data and 'database' in data['appservice']:
|
||||||
# Alte Struktur
|
|
||||||
if isinstance(data['appservice']['database'], str):
|
if isinstance(data['appservice']['database'], str):
|
||||||
data['appservice']['database'] = "sqlite:////data/bridge.db"
|
data['appservice']['database'] = "sqlite:////data/bridge.db"
|
||||||
# Neue Struktur (oft direkt unter root oder appservice.database.uri)
|
|
||||||
elif isinstance(data['appservice']['database'], dict):
|
elif isinstance(data['appservice']['database'], dict):
|
||||||
data['appservice']['database']['uri'] = "sqlite:////data/bridge.db"
|
data['appservice']['database']['uri'] = "sqlite:////data/bridge.db"
|
||||||
|
|
||||||
# Fallback: Suche nach 'database' im Root (manche Bridges)
|
|
||||||
if 'database' in data and isinstance(data['database'], dict) and 'uri' in data['database']:
|
if 'database' in data and isinstance(data['database'], dict) and 'uri' in data['database']:
|
||||||
data['database']['uri'] = "sqlite:////data/bridge.db"
|
data['database']['uri'] = "sqlite:////data/bridge.db"
|
||||||
|
|
||||||
|
|
||||||
# 2. Replace Logging Section completely
|
# 2. Replace Logging Section completely
|
||||||
data['logging'] = logging_config
|
data['logging'] = logging_config
|
||||||
|
|
||||||
@@ -80,16 +78,14 @@ for file_path in files:
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f" -> Error processing {file_path}: {e}")
|
print(f" -> Error processing {file_path}: {e}")
|
||||||
|
|
||||||
PYTHON_SCRIPT
|
PYTHON_SCRIPT
|
||||||
|
|
||||||
# 2. Prüfen ob Python/ruamel verfügbar ist. Wenn nicht, nutzen wir einen Docker Container zum Fixen!
|
# 2. Docker Container mit Python starten
|
||||||
# Da wir eh Docker haben, nutzen wir einfach das whatsapp image, da ist python+ruamel drin.
|
echo "[*] Starte Reparatur mit python:3.11-slim..."
|
||||||
echo "[*] Starte Reparatur im Docker Container (um Python-Abhängigkeiten zu nutzen)..."
|
# Wir nutzen python:3.11-slim, installieren pip deps und führen das Script aus
|
||||||
|
docker run --rm -v $(pwd):/work -w /work python:3.11-slim sh -c "pip install ruamel.yaml && python fix_yaml.py"
|
||||||
|
|
||||||
docker run --rm -v $(pwd):/work -w /work dock.mau.dev/mautrix/whatsapp:latest python3 fix_yaml.py
|
# 3. Berechtigungen
|
||||||
|
|
||||||
# 3. Berechtigungen nochmal setzen
|
|
||||||
echo "[*] Setze Berechtigungen auf 777..."
|
echo "[*] Setze Berechtigungen auf 777..."
|
||||||
chmod -R 777 data/
|
chmod -R 777 data/
|
||||||
|
|
||||||
@@ -98,4 +94,4 @@ rm fix_yaml.py
|
|||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "=== Fertig ==="
|
echo "=== Fertig ==="
|
||||||
echo "Versuche jetzt: docker compose up"
|
echo "Jetzt: docker compose up"
|
||||||
|
|||||||
Reference in New Issue
Block a user