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>
67 lines
2.1 KiB
Python
67 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Fix Neko WebRTC ports + path prefix on dy.nomadro.live."""
|
|
import paramiko
|
|
|
|
HOST = "108.174.50.68"
|
|
ROOT = "/opt/douyinWEB"
|
|
|
|
REMOTE = r"""#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
source /etc/douyinweb.env 2>/dev/null || true
|
|
export DY_PUBLIC_BASE_URL="${PUBLIC_BASE:-https://dy.nomadro.live}"
|
|
export DY_NEKO_NAT1TO1="108.174.50.68"
|
|
if command -v ufw >/dev/null 2>&1; then
|
|
ufw allow 52300:52331/tcp || true
|
|
ufw allow 52300:52331/udp || true
|
|
ufw allow 52000:52199/udp || true
|
|
fi
|
|
chmod -R 777 /opt/douyinWEB/backend/data/neko/profiles 2>/dev/null || true
|
|
cd /opt/douyinWEB/backend
|
|
.venv/bin/python - <<'PY'
|
|
from app import youtube_neko, yt_assign_db
|
|
from app.db import init_db
|
|
init_db()
|
|
groups = yt_assign_db.list_groups(include_urls=False)
|
|
r = youtube_neko.sync_for_groups(groups)
|
|
print("sync", r)
|
|
ng = youtube_neko.sync_nginx_proxy(r.get("desired", 2) or 2)
|
|
print("nginx", ng)
|
|
for i in (1, 2):
|
|
youtube_neko.instance_action(i, "restart")
|
|
s = youtube_neko._container_state(i)
|
|
print(i, s.get("status"), s.get("ready"), s.get("studio_url"))
|
|
PY
|
|
nginx -t && systemctl reload nginx
|
|
docker ps --filter name=douyinweb-neko --format '{{.Names}} {{.Ports}}'
|
|
cd /opt/douyinWEB/frontend && npm run build
|
|
systemctl restart douyinweb-web douyinweb-api
|
|
sleep 4
|
|
systemctl is-active douyinweb-web douyinweb-api
|
|
"""
|
|
|
|
|
|
def main() -> int:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, 22, "root", "Xiao4669805", timeout=45, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
sftp.put("backend/app/youtube_neko.py", f"{ROOT}/backend/app/youtube_neko.py")
|
|
sftp.put(
|
|
"frontend/src/components/YtRelayProStatusPanel.tsx",
|
|
f"{ROOT}/frontend/src/components/YtRelayProStatusPanel.tsx",
|
|
)
|
|
sftp.close()
|
|
stdin, stdout, stderr = c.exec_command(REMOTE, timeout=300)
|
|
print(stdout.read().decode("utf-8", "replace"))
|
|
err = stderr.read().decode("utf-8", "replace")
|
|
if err.strip():
|
|
print("STDERR:", err)
|
|
code = stdout.channel.recv_exit_status()
|
|
print("exit", code)
|
|
c.close()
|
|
return code
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|