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>
58 lines
1.7 KiB
Python
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_inner.py", "_recover_chooser_inner.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_inner.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=600)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|