56 lines
2.4 KiB
Python
56 lines
2.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Compare and sync relay/proxy config from 10.88.0.5 -> 10.88.0.4."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import paramiko
|
|
|
|
HOSTS = {
|
|
"10.88.0.4": ("eric", "4669805"),
|
|
"10.88.0.5": ("eric", "4669805"),
|
|
}
|
|
|
|
COMPARE_CMDS = [
|
|
("hardware_env", "cat /home/eric/d2ypp2-src/config/hardware.env 2>/dev/null"),
|
|
("hw_profile", "cat /home/eric/d2ypp2-src/config/hardware-profile.json 2>/dev/null"),
|
|
("system_stack", "grep -E 'YOUTUBE|PUSH|PROXY|SHELL|RELAY|PM2|FFMPEG' /home/eric/d2ypp2-src/config/system-stack.env 2>/dev/null | head -40"),
|
|
("proxychains_yt", "cat /home/eric/d2ypp2-src/config/proxychains-youtube.conf 2>/dev/null"),
|
|
("youtube_ini_glob", "grep -H 'video_mode\\|fast_audio\\|bitrate\\|push_proxy\\|rtmps' /home/eric/d2ypp2-src/config/youtube.youtube2__*.ini 2>/dev/null"),
|
|
("shellcrash_proxy", "grep -A30 'proxy-groups:' /tmp/ShellCrash/config.yaml 2>/dev/null | head -35"),
|
|
("shellcrash_selected", "grep -E '^(mode|mixed-port|socks-port|external-controller)' /tmp/ShellCrash/config.yaml 2>/dev/null"),
|
|
("ffmpeg_bin", "which ffmpeg; ffmpeg -version 2>&1 | head -1"),
|
|
("pm2_mode", "which pm2 2>/dev/null; PM2_HOME=/home/eric/d2ypp2-src/.pm2 pm2 list 2>/dev/null | head -8"),
|
|
("state_json", "cat /home/eric/d2ypp2-src/.process_runner/state.json 2>/dev/null"),
|
|
("ffplay_push_proxy", "grep -n 'push_proxy\\|proxychains\\|YOUTUBE_PUSH' /home/eric/d2ypp2-src/douyin_youtube_ffplay.py 2>/dev/null | head -15"),
|
|
]
|
|
|
|
|
|
def run(host: str, user: str, pw: str, cmd: str, timeout: int = 45) -> str:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(host, username=user, password=pw, timeout=15)
|
|
_, o, e = c.exec_command(cmd, timeout=timeout, get_pty=True)
|
|
out = (o.read() + e.read()).decode("utf-8", "replace")
|
|
c.close()
|
|
return out
|
|
|
|
|
|
def main() -> int:
|
|
data: dict[str, dict[str, str]] = {}
|
|
for host, (user, pw) in HOSTS.items():
|
|
data[host] = {}
|
|
print(f"\n{'#' * 60}\n# {host}\n{'#' * 60}")
|
|
for label, cmd in COMPARE_CMDS:
|
|
try:
|
|
out = run(host, user, pw, cmd)
|
|
data[host][label] = out
|
|
print(f"\n--- {label} ---")
|
|
print(out[:3500].encode("ascii", "backslashreplace").decode())
|
|
except Exception as exc:
|
|
print(f"ERR {label}: {exc}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|