#!/usr/bin/env python3 """Probe ENABLE_NEKO and Docker service state on the ARM board. Environment defaults match deploy_live_paramiko.py: LIVE_DEPLOY_HOST: 192.168.31.56 LIVE_DEPLOY_USER: orangepi LIVE_DEPLOY_PASS: orangepi """ from __future__ import annotations import os import sys try: import paramiko except ImportError: print("请先执行: pip install paramiko", file=sys.stderr) sys.exit(1) HOST = os.environ.get("LIVE_DEPLOY_HOST", "192.168.31.56") USER = os.environ.get("LIVE_DEPLOY_USER", "orangepi") PASS = os.environ.get("LIVE_DEPLOY_PASS", "orangepi") REMOTE_SH = r""" echo "--- ENABLE_NEKO in known env files ---" for f in /opt/live/config/system-stack.env /opt/live/generated/system-stack.env /home/orangepi/d2ypp2-src/config/system-stack.env; do if [ -f "$f" ]; then echo "=== $f ===" grep -E '^ENABLE_NEKO=' "$f" 2>/dev/null || echo '(no ENABLE_NEKO line)' fi done echo "--- docker: srs / neko (running or all) ---" docker ps -a --format '{{.Names}} {{.Status}}' 2>/dev/null | grep -iE 'neko|srs' || echo '(no container name matching neko|srs)' echo "--- docker ps -a (first 25) ---" docker ps -a --format '{{.Names}} {{.Status}}' 2>/dev/null | head -25 """ def main() -> int: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) try: c.connect(HOST, username=USER, password=PASS, timeout=20) except Exception as e: print(f"SSH_CONNECT_FAILED {HOST} {type(e).__name__}: {e}", file=sys.stderr) return 2 _, stdout, stderr = c.exec_command( "export LC_ALL=C.UTF-8 LANG=C.UTF-8; " + REMOTE_SH, timeout=90, ) out = stdout.read().decode("utf-8", errors="replace") err = stderr.read().decode("utf-8", errors="replace") code = stdout.channel.recv_exit_status() c.close() print(out, end="") if err.strip(): print(err, file=sys.stderr, end="") return code if __name__ == "__main__": raise SystemExit(main())