import paramiko, sys
sys.stdout.reconfigure(encoding="utf-8")

ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect("192.168.1.76", username="root", password="7309208104")

# 1) Všechny kontejnery
_, out, _ = ssh.exec_command("docker ps --format '{{.Names}}'")
print("=== Kontejnery ===")
print(out.read().decode())

# 2) Hledej SWAG
_, out, _ = ssh.exec_command("docker ps --format '{{.Names}}' | grep -i swag")
swag = out.read().decode().strip()
print(f"=== SWAG kontejner: '{swag}' ===")

if swag:
    # 3) Najdi nginx config pro msgs.buzalka.cz
    _, out, err = ssh.exec_command(
        f"docker exec {swag} find /config/nginx/proxy-confs/ -name '*msgs*' -o -name '*msg*' 2>/dev/null"
    )
    print("=== proxy-confs msgs* ===")
    print(out.read().decode())

    # 4) Zobraz hlavní nginx.conf - hledej client_max_body_size
    _, out, _ = ssh.exec_command(
        f"docker exec {swag} grep -r 'client_max_body_size' /config/nginx/ 2>/dev/null"
    )
    print("=== client_max_body_size ===")
    print(out.read().decode())

ssh.close()
