Capture Neko/WG/network hubs, Studio viewer charts, physical deploy docs, and one-shot scripts so VPS vs physical can be toggled later without losing WIP. Co-authored-by: Cursor <cursoragent@cursor.com>
67 lines
2.2 KiB
Python
67 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
PASS = "4669805"
|
|
SH = r"""#!/bin/bash
|
|
set -euo pipefail
|
|
install -m 644 /tmp/_live_landing_assign.tsx /opt/douyinWEB/frontend/src/components/YtAssignPanel.tsx
|
|
install -m 644 /tmp/_live_landing_yt.tsx /opt/douyinWEB/frontend/src/app/youtube/page.tsx
|
|
install -m 644 /tmp/_live_landing_nav.ts /opt/douyinWEB/frontend/src/lib/youtubeLiveNav.ts
|
|
systemctl stop douyinweb-web || true
|
|
cd /opt/douyinWEB/frontend && npm run build
|
|
systemctl start douyinweb-web
|
|
sleep 2
|
|
systemctl is-active douyinweb-web
|
|
echo BUILD_OK
|
|
"""
|
|
|
|
|
|
def main() -> int:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
for i in range(8):
|
|
try:
|
|
c.connect(
|
|
"107.173.30.245",
|
|
4014,
|
|
"eric",
|
|
PASS,
|
|
timeout=50,
|
|
banner_timeout=100,
|
|
allow_agent=False,
|
|
look_for_keys=False,
|
|
)
|
|
break
|
|
except Exception as ex:
|
|
print("ssh", i, type(ex).__name__, flush=True)
|
|
time.sleep(2)
|
|
else:
|
|
raise SystemExit("ssh fail")
|
|
sftp = c.open_sftp()
|
|
with sftp.file("/tmp/_live_landing_assign.tsx", "w") as f:
|
|
f.write((ROOT / "frontend/src/components/YtAssignPanel.tsx").read_text(encoding="utf-8"))
|
|
with sftp.file("/tmp/_live_landing_yt.tsx", "w") as f:
|
|
f.write((ROOT / "frontend/src/app/youtube/page.tsx").read_text(encoding="utf-8"))
|
|
with sftp.file("/tmp/_live_landing_nav.ts", "w") as f:
|
|
f.write((ROOT / "frontend/src/lib/youtubeLiveNav.ts").read_text(encoding="utf-8"))
|
|
with sftp.file("/tmp/_live_landing_deploy.sh", "w") as f:
|
|
f.write(SH)
|
|
sftp.close()
|
|
_, o, e = c.exec_command(f"echo '{PASS}' | sudo -S -p '' bash /tmp/_live_landing_deploy.sh", timeout=700)
|
|
out = (o.read() + e.read()).decode("utf-8", "replace")
|
|
print(out[-8000:] if len(out) > 8000 else out, flush=True)
|
|
c.close()
|
|
return 0 if "BUILD_OK" in out else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|