douyinWEB/scripts/_run_recover_v2b.py
eric d409e416da Ship physical dual-edge stack, Studio CDP live metrics, and ops tooling.
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>
2026-09-04 22:42:40 -05:00

64 lines
1.8 KiB
Python

# -*- coding: utf-8 -*-
import time
from pathlib import Path
import paramiko
PASS = "4669805"
ROOT = Path(__file__).resolve().parents[1]
def main() -> int:
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
for i in range(10):
try:
c.connect(
"107.173.30.245",
4014,
"eric",
PASS,
timeout=60,
banner_timeout=120,
allow_agent=False,
look_for_keys=False,
)
break
except Exception as ex:
print("ssh", i, type(ex).__name__)
time.sleep(2)
else:
return 1
sftp = c.open_sftp()
files = [
"scripts/_recover_chooser_v2.py",
"scripts/_list_neko_tabs.py",
"scripts/_scrape_all_nekos.py",
"scripts/_probe_telemetry_detail.py",
]
for rel in files:
tmp = "/tmp/" + Path(rel).name
with sftp.file(tmp, "wb") as f:
f.write((ROOT / rel).read_bytes())
print("up", rel, "->", tmp)
sftp.close()
steps = [
f"echo '{PASS}' | sudo -S -p '' python3 /tmp/_recover_chooser_v2.py",
f"echo '{PASS}' | sudo -S -p '' python3 /tmp/_list_neko_tabs.py",
f"echo '{PASS}' | sudo -S -p '' python3 /tmp/_scrape_all_nekos.py",
f"echo '{PASS}' | sudo -S -p '' /opt/douyinWEB/backend/.venv/bin/python /tmp/_probe_telemetry_detail.py",
]
for cmd in steps:
print("RUN", cmd.split("sudo")[-1][:60], flush=True)
_, o, e = c.exec_command(cmd, timeout=400)
out = (o.read() + e.read()).decode("utf-8", "replace")
print(out[-6000:] if len(out) > 6000 else out, flush=True)
c.close()
return 0
if __name__ == "__main__":
raise SystemExit(main())