# -*- coding: utf-8 -*- """Soft-fix ONLY neko-7 Chrome: restart google-chrome, fix studio URL, reopen Live tab. Does NOT touch neko 1-6. Does NOT recreate container. """ from __future__ import annotations import sys import time import paramiko sys.stdout.reconfigure(encoding="utf-8", errors="replace") PASS = "4669805" # From prior ops / channel asian streetfood STUDIO = "https://studio.youtube.com/video/i6szUMA25RM/livestreaming" REMOTE = r'''#!/bin/bash set -uo pipefail NAME=douyinweb-neko-7 STUDIO='__STUDIO__' echo === pre: proxy from container === docker exec "$NAME" python3 - <<'PY' import socket, urllib.request for host in ("host.docker.internal","172.17.0.1","172.18.0.1"): try: print(host, socket.getaddrinfo(host, 7890)[0][4]) except Exception as e: print(host, "dns_fail", e) s=socket.socket(); s.settimeout(2) try: print(host, "connect", s.connect_ex((host if host!="host.docker.internal" else socket.gethostbyname(host), 7890))) except Exception as e: print(host, "connect_err", e) finally: s.close() PY echo === soft restart google-chrome ONLY on neko-7 === docker exec "$NAME" supervisorctl restart google-chrome sleep 12 docker exec "$NAME" supervisorctl status google-chrome || true echo === wait CDP === for i in 1 2 3 4 5 6 7 8 9 10; do if docker exec "$NAME" python3 -c 'import urllib.request; urllib.request.urlopen("http://127.0.0.1:9222/json/list",timeout=2); print("ok")' 2>/dev/null | grep -q ok; then echo CDP_UP try$i break fi echo CDP_WAIT $i sleep 2 done echo === open studio tab === docker exec "$NAME" python3 - < int: c = paramiko.SSHClient() c.set_missing_host_key_policy(paramiko.AutoAddPolicy()) for i in range(12): try: c.connect( "107.173.30.245", 4014, "eric", PASS, timeout=45, banner_timeout=120, allow_agent=False, look_for_keys=False, ) break except Exception as ex: print("ssh", i, type(ex).__name__, flush=True) time.sleep(2) else: return 1 sftp = c.open_sftp() with sftp.file("/tmp/_fix_neko7.sh", "w") as f: f.write(REMOTE) sftp.close() _, o, e = c.exec_command( f"echo '{PASS}' | sudo -S -p '' bash /tmp/_fix_neko7.sh", timeout=180, ) print((o.read() + e.read()).decode("utf-8", "replace")) c.close() return 0 if __name__ == "__main__": raise SystemExit(main())