94 lines
3.2 KiB
Python
94 lines
3.2 KiB
Python
#!/usr/bin/env python3
|
|
"""Repair dylive neko-2 Tampermonkey userscripts from neko-19 (no container recreate)."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
for i in range(8):
|
|
try:
|
|
c.connect(
|
|
"107.173.30.245",
|
|
22,
|
|
"root",
|
|
"Xiao4669805",
|
|
timeout=50,
|
|
allow_agent=False,
|
|
look_for_keys=False,
|
|
banner_timeout=180,
|
|
)
|
|
break
|
|
except Exception as e:
|
|
print("retry", i, e)
|
|
time.sleep(2)
|
|
else:
|
|
raise SystemExit("ssh fail")
|
|
|
|
_i, o, e = c.exec_command(
|
|
r"""
|
|
set -euo pipefail
|
|
SRC=/opt/douyinWEB/backend/data/neko/profiles/19/Default/Local\ Extension\ Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo
|
|
DST=/opt/douyinWEB/backend/data/neko/profiles/2/Default/Local\ Extension\ Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo
|
|
|
|
echo "=== before ==="
|
|
grep -a -c "YouTube Studio Auto Dismiss" "$SRC" 2>/dev/null || echo "src_markers=0"
|
|
grep -a -c "YouTube Studio Auto Dismiss" "$DST" 2>/dev/null || echo "dst_markers=0"
|
|
du -sb "$SRC" "$DST" 2>/dev/null || true
|
|
|
|
# verify provisioning server inside neko-2
|
|
docker exec douyinweb-neko-2 sh -c 'curl -sS -m 3 http://127.0.0.1:18080/tampermonkey-provisioning.json | head -c 120; echo'
|
|
|
|
echo "=== stop chrome on neko-2 ==="
|
|
docker exec douyinweb-neko-2 supervisorctl stop google-chrome || true
|
|
sleep 2
|
|
|
|
echo "=== copy TM storage 19 -> 2 ==="
|
|
mkdir -p "$(dirname "$DST")"
|
|
rm -rf "$DST.bak-empty" 2>/dev/null || true
|
|
if [ -d "$DST" ]; then mv "$DST" "$DST.bak-empty"; fi
|
|
cp -a "$SRC" "$DST"
|
|
rm -f "$DST/LOCK" 2>/dev/null || true
|
|
chown -R 1000:1000 "$DST" 2>/dev/null || chown -R neko:neko "$DST" 2>/dev/null || true
|
|
# also ensure host uid matches container
|
|
docker exec douyinweb-neko-2 sh -c 'chown -R neko:neko "/home/neko/.config/google-chrome/Default/Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo" 2>/dev/null; rm -f "/home/neko/.config/google-chrome/Default/Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo/LOCK"'
|
|
|
|
echo "=== start chrome ==="
|
|
docker exec douyinweb-neko-2 sh -c 'rm -f /home/neko/.config/google-chrome/Singleton* 2>/dev/null; supervisorctl start google-chrome'
|
|
sleep 12
|
|
docker exec douyinweb-neko-2 supervisorctl status google-chrome
|
|
|
|
echo "=== after markers ==="
|
|
docker exec douyinweb-neko-2 sh -c '
|
|
python3 - <<"PY"
|
|
import os,re
|
|
p="/home/neko/.config/google-chrome/Default/Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo"
|
|
blob=b""
|
|
for root,_,fs in os.walk(p):
|
|
for f in fs:
|
|
try: blob+=open(os.path.join(root,f),"rb").read()
|
|
except: pass
|
|
print("blob",len(blob),"markers",len(re.findall(r"YouTube Studio Auto Dismiss", blob.decode("latin1","ignore"))))
|
|
PY
|
|
curl -sS -m 3 http://127.0.0.1:9222/json/version | head -c 100; echo
|
|
python3 - <<"PY"
|
|
import json,urllib.request
|
|
tabs=json.load(urllib.request.urlopen("http://127.0.0.1:9222/json",timeout=5))
|
|
print("tabs",len(tabs))
|
|
for t in tabs:
|
|
if "dhdgff" in (t.get("url") or "") or "studio.youtube" in (t.get("url") or ""):
|
|
print(t.get("type"), (t.get("url") or "")[:90])
|
|
PY
|
|
'
|
|
echo FIX_DONE
|
|
""",
|
|
timeout=180,
|
|
)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"))
|
|
c.close()
|