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>
66 lines
1.9 KiB
Python
66 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Deploy ticker dedupe fix only — no Chrome touch."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
PASS = "4669805"
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
SH = r"""#!/bin/bash
|
|
set -euo pipefail
|
|
install -m 644 /tmp/_fix_ticker.tsx /opt/douyinWEB/frontend/src/components/YouTubeLiveTicker.tsx
|
|
BEFORE=$(docker ps -q --filter name=douyinweb-neko- | wc -l | tr -d ' ')
|
|
systemctl stop douyinweb-web || true
|
|
cd /opt/douyinWEB/frontend && npm run build
|
|
systemctl start douyinweb-web
|
|
sleep 2
|
|
systemctl is-active douyinweb-web
|
|
AFTER=$(docker ps -q --filter name=douyinweb-neko- | wc -l | tr -d ' ')
|
|
echo "NEKO_BEFORE=$BEFORE NEKO_AFTER=$AFTER"
|
|
echo BUILD_OK
|
|
"""
|
|
|
|
|
|
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()
|
|
with sftp.file("/tmp/_fix_ticker.tsx", "wb") as f:
|
|
f.write((ROOT / "frontend/src/components/YouTubeLiveTicker.tsx").read_bytes())
|
|
with sftp.file("/tmp/_fix_ticker.sh", "w") as f:
|
|
f.write(SH)
|
|
sftp.close()
|
|
_, o, e = c.exec_command(f"echo '{PASS}' | sudo -S -p '' bash /tmp/_fix_ticker.sh", timeout=400)
|
|
out = (o.read() + e.read()).decode("utf-8", "replace")
|
|
print(out[-8000:] if len(out) > 8000 else out)
|
|
c.close()
|
|
return 0 if "BUILD_OK" in out else 1
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|