81 lines
2.4 KiB
Python
81 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Verify TM on both hosts; revive neko-2 if needed (docker start only)."""
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
import time
|
|
|
|
import paramiko
|
|
|
|
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
|
|
|
|
|
|
def connect(host):
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
for i in range(8):
|
|
try:
|
|
c.connect(
|
|
host,
|
|
22,
|
|
"root",
|
|
"Xiao4669805",
|
|
timeout=50,
|
|
allow_agent=False,
|
|
look_for_keys=False,
|
|
banner_timeout=180,
|
|
)
|
|
return c
|
|
except Exception as e:
|
|
print("retry", host, i, e)
|
|
time.sleep(2)
|
|
raise SystemExit("fail")
|
|
|
|
|
|
def run(c, cmd, t=120):
|
|
_i, o, e = c.exec_command(cmd, timeout=t)
|
|
print((o.read() + e.read()).decode("utf-8", "replace"), flush=True)
|
|
|
|
|
|
cmd = r"""
|
|
set +e
|
|
echo '--- containers ---'
|
|
docker ps -a --filter name=douyinweb-neko --format '{{.Names}} {{.Status}}' | sort -V
|
|
# ensure neko-2 up if assign wants it (hackrobotlite)
|
|
if docker inspect douyinweb-neko-2 >/dev/null 2>&1; then
|
|
if ! docker inspect -f '{{.State.Running}}' douyinweb-neko-2 | grep -q true; then
|
|
echo 'starting neko-2'
|
|
docker start douyinweb-neko-2
|
|
sleep 10
|
|
fi
|
|
fi
|
|
for name in $(docker ps --format '{{.Names}}' | grep '^douyinweb-neko-' | sort -V); do
|
|
docker exec "$name" python3 -c "
|
|
import os,re
|
|
p='/home/neko/.config/google-chrome/Default/Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo'
|
|
b=b''
|
|
for r,_,fs in os.walk(p):
|
|
for f in fs:
|
|
try: b+=open(os.path.join(r,f),'rb').read()
|
|
except: pass
|
|
print('$name', 'OK' if b'YouTube Studio Auto Dismiss' in b else 'EMPTY', 'blob', len(b))
|
|
" 2>&1
|
|
docker exec "$name" supervisorctl status google-chrome 2>&1 | head -1
|
|
done
|
|
# seed check
|
|
SEED='/opt/douyinWEB/backend/neko/tampermonkey-seed/Default/Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo'
|
|
echo -n 'seed '; grep -a -R -q 'YouTube Studio Auto Dismiss' \"$SEED\" && echo OK || echo EMPTY
|
|
curl -sS -m 5 -o /dev/null -w 'neko2_http:%{http_code}\n' http://127.0.0.1:9201/ 2>/dev/null || true
|
|
"""
|
|
|
|
print("===== dylive =====", flush=True)
|
|
dl = connect("107.173.30.245")
|
|
run(dl, cmd)
|
|
dl.close()
|
|
|
|
print("===== dy =====", flush=True)
|
|
dy = connect("108.174.50.68")
|
|
run(dy, cmd.replace("9201", "9209")) # just don't care about port on dy
|
|
dy.close()
|
|
print("DONE")
|