Erste Version
This commit is contained in:
40
deps.py
Normal file
40
deps.py
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/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).")
|
||||
Reference in New Issue
Block a user