From 77f57b84ba1cf7f25228a9720d8156320d5ed624 Mon Sep 17 00:00:00 2001 From: jonnybravo Date: Tue, 8 Sep 2026 14:54:10 +0200 Subject: [PATCH] all# --- scp_copy.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scp_copy.py b/scp_copy.py index 07c7c8b..7163362 100644 --- a/scp_copy.py +++ b/scp_copy.py @@ -7,6 +7,11 @@ def copy_files_scp(scr: str = "/home/jonnybravo/Dokumente/", dest: str = 'ras-dan-01:/home/jonnybravo/.docker/hugo/content/', container: str = "hugo"): dest_host = dest.split(":")[0] + dest_dir = dest.split(":")[1].rstrip("/") if ":" in dest else dest + # compose.yml liegt zwei Ebenen über content/ + # ~/.docker/hugo/content/ → ~/.docker/hugo/docker-compose.yml + compose_file = os.path.join(os.path.dirname(dest_dir), "docker-compose.yml") + ssh_opts = ["ssh", "-o", "StrictHostKeyChecking=no", dest_host] list_all_files_md = [os.path.join(scr, a) for a in os.listdir(scr) if a.endswith(".md")] for file in list_all_files_md: cmd = ["scp", "-o", "StrictHostKeyChecking=no", file, dest ] @@ -21,8 +26,7 @@ def copy_files_scp(scr: str = "/home/jonnybravo/Dokumente/", log.log("Es wird kein Container neugestartet", status="INFO") else: log.log(f"Der {container} wird auf {dest_host} via SSH neugestartet !", status="INFO") - docker_cmd = ["ssh", "-o", "StrictHostKeyChecking=no", dest_host, - "docker", "compose", "-f", ".docker/hugo/docker-compose.yml", "restart", container] + docker_cmd = ssh_opts + ["docker", "compose", "-f", compose_file, "restart", container] result_docker = subprocess.run(docker_cmd, capture_output=True, text=True) if result_docker.returncode != 0: log.log(f"Der {container} konnte nicht gestartet werden: {result_docker.stderr.strip() or result_docker.stdout.strip()}", status="ERROR") @@ -34,9 +38,8 @@ def copy_files_scp(scr: str = "/home/jonnybravo/Dokumente/", deadline = time.time() + 15 while time.time() < deadline: check = subprocess.run( - ["ssh", "-o", "StrictHostKeyChecking=no", dest_host, - "curl", "-sk", "--max-time", "2", "-o", "/dev/null", "-w", "%{http_code}", - "https://localhost:5443/"], + ssh_opts + ["curl", "-sk", "--max-time", "2", "-o", "/dev/null", + "-w", "%{http_code}", "https://localhost:5443/"], capture_output=True, text=True, ) if check.stdout.strip() == "200":