douyinWEB/scripts/_run_recover_v2.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

58 lines
1.7 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()
for rel, tmp in [
("scripts/_recover_chooser_v2.py", "_recover_chooser_v2.py"),
("scripts/_list_neko_tabs.py", "_list_neko_tabs.py"),
("scripts/_scrape_all_nekos.py", "_scrape_all_nekos.py"),
("scripts/_probe_telemetry_detail.py", "_probe_telemetry_detail.py"),
]:
with sftp.file(f"/tmp/{tmp}", "wb") as f:
f.write((ROOT / rel).read_bytes())
print("up", rel)
sftp.close()
cmd = (
f"echo '{PASS}' | sudo -S -p '' bash -lc '"
"python3 /tmp/_recover_chooser_v2.py; "
"echo TABS; python3 /tmp/_list_neko_tabs.py; "
"echo SCRAPE; python3 /tmp/_scrape_all_nekos.py; "
"echo PROBE; /opt/douyinWEB/backend/.venv/bin/python /tmp/_probe_telemetry_detail.py'"
)
_, o, e = c.exec_command(cmd, timeout=700)
print((o.read() + e.read()).decode("utf-8", "replace"))
c.close()
return 0
if __name__ == "__main__":
raise SystemExit(main())