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

77 lines
2.2 KiB
Python

#!/usr/bin/env python3
"""Read-only map: where dy.nomadro.live / .com Caddy and S3 live."""
from __future__ import annotations
import sys
import time
import paramiko
sys.stdout.reconfigure(encoding="utf-8", errors="replace")
HOSTS = [
("vps-dylive", "107.173.30.245"),
("vps-dy", "108.174.50.68"),
]
def run(host, script, timeout=90):
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
for i in range(8):
try:
c.connect(
host,
22,
"root",
"Xiao4669805",
timeout=40,
allow_agent=False,
look_for_keys=False,
banner_timeout=120,
)
break
except Exception as e:
print(f"retry {host} {i}: {e}", flush=True)
time.sleep(2 + i)
else:
raise SystemExit(f"ssh fail {host}")
_i, o, e = c.exec_command(script, timeout=timeout)
out = (o.read() + e.read()).decode("utf-8", "replace")
c.close()
return out
SCRIPT = r"""
set +e
echo '=== hostname / ips ==='
hostname -f 2>/dev/null; hostname
ip -4 addr show scope global | awk '/inet /{print $2,$NF}'
echo
echo '=== caddy present? ==='
systemctl is-active caddy 2>/dev/null
ss -lntp | grep -E ':443|:80|:8333|:28333|:8014|:4015' | head -30
echo
echo '=== site files mentioning dy.nomadro.live / douyin-covers ==='
grep -Rnl 'dy.nomadro.live\|douyin-covers\|s3.nomadro' /etc/caddy 2>/dev/null | head -40
for f in /etc/caddy/sites/*live* /etc/caddy/sites/dy* /etc/caddy/Caddyfile /etc/caddy/sites/s3*; do
[ -f "$f" ] || continue
echo "---- $f ----"
grep -nE 'dy\.nomadro\.(live|com)|douyin-covers|8333|28333|covers|s3\.nomadro' "$f" 2>/dev/null | head -40
done
echo
echo '=== seaweed / s3 units ==='
systemctl is-active seaweed-s3.service douyinweb-s3.service 2>/dev/null
ls /etc/seaweedfs/ 2>/dev/null
echo
echo '=== frp-aux ==='
systemctl is-active dy-frp-http-aux.service 2>/dev/null
systemctl status dy-frp-http-aux.service --no-pager -l 2>&1 | head -25
echo HOST_DONE
"""
for label, host in HOSTS:
print(f"\n######## {label} {host} ########", flush=True)
print(run(host, SCRIPT), flush=True)
print("ALL_DONE", flush=True)