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>
66 lines
2.2 KiB
Python
66 lines
2.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Restore TM storage backup and fix ownership on neko-3."""
|
|
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
|
|
name=douyinweb-neko-3
|
|
docker exec "$name" supervisorctl stop google-chrome
|
|
docker exec "$name" sh -c '
|
|
ext=dhdgffkkebhmkfjojejmpbldmpobfkfo
|
|
base=/home/neko/.config/chromium/Default
|
|
local="$base/Local Extension Settings/$ext"
|
|
managed="$base/Managed Extension Settings/$ext"
|
|
bak=$(ls -d "$base/Local Extension Settings/${ext}.bak-"* 2>/dev/null | tail -1 || true)
|
|
mbak=$(ls -d "$base/Managed Extension Settings/${ext}.bak-"* 2>/dev/null | tail -1 || true)
|
|
rm -rf "$local" "$managed"
|
|
if [ -n "$bak" ] && [ -d "$bak" ]; then
|
|
cp -a "$bak" "$local"
|
|
echo "restored_local $bak"
|
|
else
|
|
mkdir -p "$local"
|
|
echo "created_empty_local"
|
|
fi
|
|
if [ -n "$mbak" ] && [ -d "$mbak" ]; then
|
|
cp -a "$mbak" "$managed"
|
|
echo "restored_managed $mbak"
|
|
else
|
|
mkdir -p "$managed"
|
|
echo "created_empty_managed"
|
|
fi
|
|
chown -R neko:neko "$base/Local Extension Settings" "$base/Managed Extension Settings"
|
|
chmod -R u+rwX "$base/Local Extension Settings" "$base/Managed Extension Settings"
|
|
rm -f "$local/LOCK" "$managed/LOCK" 2>/dev/null || true
|
|
ls -la "$local" | head -8
|
|
'
|
|
docker exec "$name" supervisorctl start google-chrome
|
|
sleep 10
|
|
docker exec "$name" sh -c 'grep -R -a "YouTube Studio Auto Dismiss" "/home/neko/.config/chromium/Default/Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo" 2>/dev/null | wc -c'
|
|
docker exec "$name" python3 -c "import json,urllib.request; tabs=json.load(urllib.request.urlopen('http://127.0.0.1:9222/json/list',timeout=5)); print('tabs',len(tabs)); [print((t.get('url') or '')[:110]) for t in tabs if 'tampermonkey' in (t.get('url') or '')]"
|
|
"""
|
|
|
|
|
|
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=180)
|
|
print(o.read().decode("utf-8", "replace"))
|
|
err = e.read().decode("utf-8", "replace")
|
|
if err.strip():
|
|
print("ERR", err[:2000])
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|