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>
77 lines
2.2 KiB
Python
77 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Fix stream-key autofill + clear polluted hackrobot keys on VPS."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
HOST = "108.174.50.68"
|
|
PASS = "Xiao4669805"
|
|
REPO = "/opt/douyinWEB"
|
|
FILES = [
|
|
"backend/app/yt_assign_db.py",
|
|
"frontend/src/components/YtAssignPanel.tsx",
|
|
]
|
|
|
|
|
|
def main() -> None:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, 22, "root", PASS, timeout=60, allow_agent=False, look_for_keys=False)
|
|
sftp = c.open_sftp()
|
|
for rel in FILES:
|
|
sftp.put(str(ROOT / rel), f"{REPO}/{rel}")
|
|
print("uploaded", rel)
|
|
sftp.close()
|
|
|
|
cmd = r"""
|
|
set -e
|
|
systemctl restart douyinweb-api
|
|
cd /opt/douyinWEB/frontend && npm run build
|
|
systemctl restart douyinweb-web
|
|
sleep 3
|
|
cd /opt/douyinWEB/backend && .venv/bin/python - <<'PY'
|
|
from app import yt_assign_db
|
|
from app.config import settings
|
|
|
|
banned = {
|
|
"hackrobot",
|
|
"douyinweb",
|
|
"xiao4669805@",
|
|
"xiao4669805",
|
|
str(settings.admin_username or "").strip().lower(),
|
|
str(settings.admin_password or "").strip().lower(),
|
|
str(settings.neko_user_pass or "").strip().lower(),
|
|
str(settings.neko_admin_pass or "").strip().lower(),
|
|
}
|
|
banned = {x for x in banned if x}
|
|
cleared = []
|
|
for g in yt_assign_db.list_groups(include_urls=False):
|
|
full = yt_assign_db.get_group(g["id"]) or {}
|
|
sk = str(full.get("stream_key") or "").strip()
|
|
if sk and sk.lower() in banned:
|
|
yt_assign_db.update_group(g["id"], stream_key="")
|
|
cleared.append((g.get("name"), sk[:20]))
|
|
print("cleared_polluted_keys", cleared)
|
|
for g in yt_assign_db.list_groups(include_urls=False):
|
|
print(g.get("name"), "has_key", g.get("has_stream_key"), "masked", g.get("stream_key_masked"))
|
|
PY
|
|
systemctl is-active douyinweb-api
|
|
systemctl is-active douyinweb-web
|
|
"""
|
|
_i, o, e = c.exec_command(cmd, timeout=700)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
err = e.read().decode("utf-8", "replace")
|
|
if err.strip():
|
|
print("STDERR", err[-2000:])
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|