43 lines
1.1 KiB
Python
43 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
from __future__ import annotations
|
|
|
|
import os
|
|
import sys
|
|
|
|
import paramiko
|
|
|
|
from load_dev_env import ssh_config
|
|
|
|
HOST, USER, SSH_PASSWORD = ssh_config()
|
|
|
|
|
|
|
|
CMDS = [
|
|
"docker ps -a | grep -i ntfy || true",
|
|
"curl -sI http://127.0.0.1:9180/ | head -8",
|
|
"curl -sI https://ntfy.nomadro.cn/ | head -10",
|
|
"curl -skI https://ntfy.nomadro.cn/ | head -10",
|
|
"sudo cat /www/server/panel/vhost/nginx/ntfy.nomadro.cn.conf 2>/dev/null | head -60",
|
|
"sudo ls /etc/letsencrypt/live/ | grep ntfy || true",
|
|
"sudo certbot certificates 2>/dev/null | grep -A3 ntfy || true",
|
|
]
|
|
|
|
|
|
def main() -> None:
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, username=USER, password=PASSWORD, timeout=30)
|
|
try:
|
|
for cmd in CMDS:
|
|
full = f"echo '{PASSWORD}' | sudo -S bash -lc \"{cmd}\""
|
|
print(f"\n=== {cmd} ===")
|
|
_, o, e = c.exec_command(full, timeout=60, get_pty=True)
|
|
sys.stdout.buffer.write(o.read())
|
|
sys.stdout.buffer.write(e.read())
|
|
finally:
|
|
c.close()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|