douyinWEB/scripts/_probe_dy_postinstall.py
2026-09-13 22:10:49 -05:00

88 lines
2.8 KiB
Python

#!/usr/bin/env python3
"""Post-install gap check on dy.nomadro.live (108.174.50.68)."""
from __future__ import annotations
import json
import sys
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
def main() -> None:
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,
banner_timeout=120,
)
cmd = r"""
set +e
echo ===UNITS===
systemctl is-active douyinweb-api douyinweb-web douyinweb-pb douyinweb-yt douyinweb-s3 douyinweb-sw-master
echo ===DOCKER===
docker --version 2>/dev/null || echo NO_DOCKER
docker ps -a --filter name=douyinweb-neko --format '{{.Names}} {{.Status}}' 2>/dev/null | head
echo ===HEALTH===
curl -fsS http://127.0.0.1:8014/api/health 2>/dev/null | head -c 500; echo
echo ===LOGIN===
curl -sS -o /tmp/login.json -w '%{http_code}' -X POST http://127.0.0.1:8014/api/auth/login \
-H 'Content-Type: application/json' \
-d '{"username":"hackrobot","password":"Xiao4669805@"}'; echo
cat /tmp/login.json; echo
echo ===SETTINGS_OAUTH===
cd /opt/douyinWEB/backend
./.venv/bin/python - <<'PY'
from app import db
import json
sm = db.get_settings_map()
keys = sorted(k for k in sm if 'oauth' in k.lower() or 'neko' in k.lower() or 'relay' in k.lower() or 'shorts' in k.lower())
print('interesting_keys', keys[:80])
for k in ('shorts_oauth_profiles','youtube_relay_enabled','neko_mem_limit','dy_cookie'):
v = sm.get(k)
if isinstance(v, (dict, list)):
print(k, json.dumps(v, ensure_ascii=False)[:300])
else:
s = str(v or '')
if 'cookie' in k or 'secret' in k or 'token' in k:
print(k, f'len={len(s)}')
else:
print(k, s[:120])
# channels / assign
try:
ch = db.list_shorts_channels()
print('shorts_channels', len(ch))
except Exception as e:
print('shorts_err', e)
try:
from app import yt_assign_db
print('assign_groups', len(yt_assign_db.list_groups(include_urls=False)))
except Exception as e:
print('assign_err', e)
rooms = db.list_rooms()
if isinstance(rooms, dict):
print('rooms_total', rooms.get('total'), 'n', len(rooms.get('rooms') or []))
else:
print('rooms_raw', type(rooms), len(rooms) if hasattr(rooms,'__len__') else rooms)
PY
echo ===LEFTOVER_SECRETS===
ls -la /root/*client_secret* /opt/*client_secret* /tmp/*client_secret* 2>/dev/null | head
find /root /var/backups /opt -name 'client_secret*.json' 2>/dev/null | head
echo ===NEKO_ASSETS===
ls /opt/douyinWEB/backend/neko/browser-launch.sh /opt/douyinWEB/backend/neko/tampermonkey-seed 2>/dev/null | head
"""
_i, o, e = c.exec_command(cmd, timeout=90)
print((o.read() + e.read()).decode("utf-8", "replace"))
c.close()
if __name__ == "__main__":
main()