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>
76 lines
2.5 KiB
Python
76 lines
2.5 KiB
Python
# -*- coding: utf-8 -*-
|
|
from __future__ import annotations
|
|
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
PASS = "4669805"
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
FILES = [
|
|
("backend/app/youtube_neko.py", "/opt/douyinWEB/backend/app/youtube_neko.py", "_c4_neko.py"),
|
|
("backend/neko/cdp_studio_scrape.py", "/opt/douyinWEB/backend/neko/cdp_studio_scrape.py", "_c4_scrape.py"),
|
|
("backend/neko/live-ops-extension/content.js", "/opt/douyinWEB/backend/neko/live-ops-extension/content.js", "_c4_ct.js"),
|
|
("scripts/_probe_telemetry_detail.py", "/tmp/_probe_telemetry_detail.py", "_probe_telemetry_detail.py"),
|
|
("scripts/_scrape_all_nekos.py", "/tmp/_scrape_all_nekos.py", "_scrape_all_nekos.py"),
|
|
]
|
|
|
|
SH = r"""#!/bin/bash
|
|
set -euo pipefail
|
|
install -m 644 /tmp/_c4_neko.py /opt/douyinWEB/backend/app/youtube_neko.py
|
|
install -m 644 /tmp/_c4_scrape.py /opt/douyinWEB/backend/neko/cdp_studio_scrape.py
|
|
install -m 644 /tmp/_c4_ct.js /opt/douyinWEB/backend/neko/live-ops-extension/content.js
|
|
cd /opt/douyinWEB/backend && .venv/bin/python -m py_compile app/youtube_neko.py
|
|
BEFORE=$(docker ps -q --filter name=douyinweb-neko- | wc -l | tr -d ' ')
|
|
systemctl restart douyinweb-api
|
|
sleep 4
|
|
systemctl is-active douyinweb-api
|
|
AFTER=$(docker ps -q --filter name=douyinweb-neko- | wc -l | tr -d ' ')
|
|
echo "NEKO_BEFORE=$BEFORE NEKO_AFTER=$AFTER"
|
|
echo SCRAPE_ALL
|
|
python3 /tmp/_scrape_all_nekos.py
|
|
echo PROBE
|
|
.venv/bin/python /tmp/_probe_telemetry_detail.py
|
|
"""
|
|
|
|
|
|
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, _dst, tmp in FILES:
|
|
with sftp.file(f"/tmp/{tmp}", "wb") as f:
|
|
f.write((ROOT / rel).read_bytes())
|
|
print("up", rel)
|
|
with sftp.file("/tmp/_c4_deploy.sh", "w") as f:
|
|
f.write(SH)
|
|
sftp.close()
|
|
_, o, e = c.exec_command(f"echo '{PASS}' | sudo -S -p '' bash /tmp/_c4_deploy.sh", timeout=420)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|