#!/usr/bin/env python3 import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) from deploy_remote import connect, sudo # noqa: E402 local = Path(r"c:\laragon\www\light-otantik-nux\deploy\bootstrap.sh") data = local.read_bytes().replace(b"\r\n", b"\n") client = connect() sftp = client.open_sftp() with sftp.file("/tmp/bootstrap.sh", "wb") as f: f.write(data) sftp.close() print("bootstrap uploaded", flush=True) code, out = sudo( client, "cp /tmp/bootstrap.sh /tmp/woyla-deploy/bootstrap.sh && chmod +x /tmp/woyla-deploy/bootstrap.sh && set -a && . /root/woyla.env && set +a && bash /tmp/woyla-deploy/bootstrap.sh > /tmp/bootstrap.log 2>&1; echo BOOTSTRAP_DONE:$?", timeout=700, ) sys.stdout.buffer.write((out + "\n").encode("utf-8", errors="replace")) code2, tail = sudo(client, "tail -n 60 /tmp/bootstrap.log") sys.stdout.buffer.write((tail + f"\nEXIT_CODE {code}\n").encode("utf-8", errors="replace")) client.close() sys.exit(0 if "BOOTSTRAP_DONE:0" in out or "[8/8] done" in tail else 1)