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>
79 lines
2.6 KiB
Python
79 lines
2.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Recreate neko-3 so bind-mounted browser-launch.sh updates, then repair TM."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
HOST = "108.174.50.68"
|
|
PASS = "Xiao4669805"
|
|
|
|
CMD = r"""
|
|
set -e
|
|
cd /opt/douyinWEB/backend
|
|
.venv/bin/python - <<'PY'
|
|
from app import youtube_neko, yt_assign_db
|
|
|
|
groups = yt_assign_db.list_groups(include_urls=False)
|
|
desired = max([int(g.get("neko_instance_id") or 0) for g in groups] + [0])
|
|
compose = youtube_neko._compose_path()
|
|
compose.write_text(youtube_neko._render_compose(desired), encoding="utf-8")
|
|
code, out = youtube_neko._run(
|
|
youtube_neko._compose_cmd("up", "-d", "--force-recreate", "neko3"),
|
|
timeout=600,
|
|
)
|
|
print("recreate", code, out[-500:])
|
|
PY
|
|
|
|
sleep 5
|
|
echo "=== md5 after recreate ==="
|
|
md5sum /opt/douyinWEB/backend/neko/browser-launch.sh
|
|
docker exec douyinweb-neko-3 md5sum /etc/neko/browser-launch.sh
|
|
docker exec douyinweb-neko-3 grep -n 'rm -rf.*Managed Extension Settings' /etc/neko/browser-launch.sh && echo BAD || echo OK
|
|
|
|
sleep 15
|
|
docker exec douyinweb-neko-3 supervisorctl status google-chrome
|
|
docker exec douyinweb-neko-3 sh -c 'grep -R -a "YouTube Studio Auto Dismiss" "/home/neko/.config/google-chrome/Default/Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo" 2>/dev/null | wc -c'
|
|
|
|
docker exec douyinweb-neko-3 python3 - <<'PY'
|
|
import json, urllib.request
|
|
junk = ("tampermonkey.net/changelog", "tampermonkey.net/installed")
|
|
with urllib.request.urlopen("http://127.0.0.1:9222/json/list", timeout=8) as resp:
|
|
tabs = json.loads(resp.read().decode())
|
|
for tab in tabs:
|
|
url = tab.get("url") or ""
|
|
if any(x in url for x in junk):
|
|
tid = tab.get("id")
|
|
if tid:
|
|
urllib.request.urlopen(f"http://127.0.0.1:9222/json/close/{tid}", timeout=3)
|
|
print("closed", url[:90])
|
|
req = urllib.request.Request(
|
|
"http://127.0.0.1:9222/json/new",
|
|
data=json.dumps({"url": "chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/dashboard.html"}).encode(),
|
|
headers={"Content-Type": "application/json"},
|
|
)
|
|
with urllib.request.urlopen(req, timeout=5) as resp:
|
|
tab = json.loads(resp.read().decode())
|
|
print("dashboard", (tab.get("url") or "")[:100])
|
|
PY
|
|
"""
|
|
|
|
|
|
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)
|
|
_i, o, e = c.exec_command(CMD, timeout=600)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
err = e.read().decode("utf-8", "replace")
|
|
if err.strip():
|
|
print("ERR", err[:3000])
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|