From 10211adf5b1b8719e4c96cdb3998bd827bb0cfac Mon Sep 17 00:00:00 2001 From: "info@pi-farm.de" Date: Tue, 3 Mar 2026 16:42:02 +0000 Subject: [PATCH] pi_admin/main.py aktualisiert --- pi_admin/main.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pi_admin/main.py b/pi_admin/main.py index c19faec..a6434ce 100644 --- a/pi_admin/main.py +++ b/pi_admin/main.py @@ -48,6 +48,24 @@ def run_ssh_cmd(ip, user, password, cmd): except Exception as e: return str(e) +# --- Ollama installation Logic --- + +def install_ollama(ip, user, password, is_local=False): + install_cmd = "curl -fsSL https://ollama.com/install.sh | sh" + + if is_local: + # Installation auf dem Master-Pi + import subprocess + try: + process = subprocess.Popen(install_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr = process.communicate() + return f"Lokal: {stdout.decode()}" + except Exception as e: + return f"Lokal Fehler: {str(e)}" + else: + # Installation auf einem Worker-Node via SSH + return run_ssh_cmd(ip, user, password, install_cmd) + # --- Chat & AI Logic --- @app.websocket("/ws/chat")