This commit is contained in:
+8
-5
@@ -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":
|
||||
|
||||
Reference in New Issue
Block a user