41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
#!/usr/bin/env python3
|
||
import shutil
|
||
import subprocess
|
||
import sys
|
||
from typing import List
|
||
|
||
REQUIRED_BINARIES = ["ansible", "ssh", "scp"]
|
||
|
||
|
||
def check_dependencies() -> List[str]:
|
||
"""Prüft, welche Binaries fehlen."""
|
||
missing = []
|
||
for binary in REQUIRED_BINARIES:
|
||
if shutil.which(binary) is None:
|
||
missing.append(binary)
|
||
return missing
|
||
|
||
|
||
def install_dependencies(missing: List[str]) -> None:
|
||
"""
|
||
Versucht, fehlende Pakete über apt zu installieren.
|
||
Achtung: sehr Debian/Raspberry-spezifisch – bei Bedarf anpassen.
|
||
"""
|
||
print("Starte Installation der fehlenden Abhängigkeiten...")
|
||
cmds = []
|
||
|
||
if "ansible" in missing:
|
||
cmds.append(["sudo", "apt", "update"])
|
||
cmds.append(["sudo", "apt", "install", "-y", "ansible"])
|
||
if "ssh" in missing or "scp" in missing:
|
||
cmds.append(["sudo", "apt", "install", "-y", "openssh-client"])
|
||
|
||
for cmd in cmds:
|
||
print("→", " ".join(cmd))
|
||
try:
|
||
subprocess.run(cmd, check=False)
|
||
except Exception as exc:
|
||
print(f"Fehler beim Ausführen von {' '.join(cmd)}: {exc}")
|
||
|
||
print("Abhängigkeiten-Installation abgeschlossen (ggf. Fehlerausgabe oben prüfen).")
|