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>
71 lines
2.4 KiB
Python
71 lines
2.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Force host-side Tampermonkey seed + chrome restart on VPS."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("108.174.50.68", 22, "root", "Xiao4669805", timeout=45, allow_agent=False, look_for_keys=False)
|
|
s = c.open_sftp()
|
|
s.put(
|
|
r"c:\Users\admin\Desktop\douyinWEB\backend\app\youtube_neko.py",
|
|
"/opt/douyinWEB/backend/app/youtube_neko.py",
|
|
)
|
|
s.close()
|
|
|
|
REMOTE = r"""#!/bin/bash
|
|
set -e
|
|
systemctl restart douyinweb-api
|
|
sleep 2
|
|
# stop chrome containers before writing profile
|
|
docker stop -t 5 douyinweb-neko-1 || true
|
|
cd /opt/douyinWEB/backend
|
|
DY_NEKO_TAMPERMONKEY_REPAIR=1 .venv/bin/python - <<'PY'
|
|
from pathlib import Path
|
|
from app import youtube_neko
|
|
for i in (1, 2):
|
|
p = youtube_neko._ensure_profile(i)
|
|
les = p / "Default" / "Local Extension Settings" / youtube_neko._TM_EXT_ID
|
|
ext = p / "Default" / "Extensions" / youtube_neko._TM_EXT_ID
|
|
print(i, "ext", ext.is_dir(), "les", les.is_dir())
|
|
hit = False
|
|
if les.is_dir():
|
|
for f in les.iterdir():
|
|
if f.is_file() and b"YouTube Studio Auto Dismiss" in f.read_bytes():
|
|
hit = True
|
|
break
|
|
print(i, "script", hit)
|
|
PY
|
|
# start enabled only
|
|
docker start douyinweb-neko-1
|
|
sleep 10
|
|
docker exec douyinweb-neko-1 supervisorctl status
|
|
ls /opt/douyinWEB/backend/data/neko/profiles/1/Default/Extensions
|
|
ls "/opt/douyinWEB/backend/data/neko/profiles/1/Default/Local Extension Settings"
|
|
grep -a -c "YouTube Studio Auto Dismiss" /opt/douyinWEB/backend/data/neko/profiles/1/Default/Local\ Extension\ Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo/* | head
|
|
python3 - <<'PY'
|
|
import json
|
|
from pathlib import Path
|
|
p=Path('/opt/douyinWEB/backend/data/neko/profiles/1/Default/Preferences')
|
|
d=json.loads(p.read_text())
|
|
tm=((d.get('extensions') or {}).get('settings') or {}).get('dhdgffkkebhmkfjojejmpbldmpobfkfo')
|
|
print('tm_state', (tm or {}).get('state'), 'dev', ((d.get('extensions') or {}).get('ui') or {}).get('developer_mode'))
|
|
PY
|
|
"""
|
|
s = c.open_sftp()
|
|
with s.file("/tmp/force_tm_seed.sh", "w") as f:
|
|
f.write(REMOTE)
|
|
s.close()
|
|
_i, o, e = c.exec_command("bash /tmp/force_tm_seed.sh", timeout=180)
|
|
o.channel.settimeout(180)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
err = e.read().decode("utf-8", "replace")
|
|
if err.strip():
|
|
print("STDERR", err[:1500])
|
|
c.close()
|