Files
exposedgays/deploy/grep-remote-config.py

31 lines
1.3 KiB
Python

#!/usr/bin/env python3
import paramiko
PASS = "Bbt9115xty9176!"
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("10.10.0.10", username="localadministrator", password=PASS, timeout=30)
_, o, e = c.exec_command(
"sudo journalctl -u cloudflared --no-pager -n 50 | grep 'Updated to new configuration' | tail -1",
timeout=30,
)
o.channel.recv_exit_status()
line = (o.read() + e.read()).decode()
print("exposedgays in remote:", "exposedgays" in line)
for h in ["exposedgays.com", "www.exposedgays.com", "thepinkpulse.com", "avbeat.com"]:
print(f" {h}: {h in line}")
# restart to pick up dashboard changes
_, o2, e2 = c.exec_command(f"echo '{PASS}' | sudo -S systemctl restart cloudflared && sleep 8 && sudo journalctl -u cloudflared --no-pager -n 8", timeout=60)
o2.channel.recv_exit_status()
out = (o2.read() + e2.read()).decode()
print("\nAfter restart:")
print("exposedgays:", "exposedgays" in out)
for cmd in [
"curl -sSI --max-time 25 https://exposedgays.com/ 2>&1 | head -15",
"curl -sSI --max-time 25 https://www.exposedgays.com/ 2>&1 | head -15",
"curl -sSL --max-time 25 https://www.exposedgays.com/ 2>&1 | head -c 350",
]:
print(f"\n=== {cmd} ===")
_, o, e = c.exec_command(cmd, timeout=35)
o.channel.recv_exit_status()
print((o.read() + e.read()).decode(errors="replace")[:2000])
c.close()