#!/usr/bin/env python3 """ One-shot production verification for the wifi-otantik VPS (83.147.38.107). Run this from the project root on your machine (same place the other scripts/*.py live, since it imports vps_ssh.py from this folder): python scripts\\verify_production.py > verify_output.txt Then share verify_output.txt (or paste the terminal output) back so it can be reviewed. This script is READ-ONLY - it does not change anything on the server, it only inspects it. """ from __future__ import annotations import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) import vps_ssh # noqa: E402 APP_ROOT = "/var/www/wifi-otantik" SECTIONS: list[tuple[str, str]] = [ ("SYSTEM", "uname -a; echo; uptime; echo; df -h /; echo; free -h"), ( "SERVICES", "systemctl is-active nginx php8.3-fpm mariadb 2>&1; " "systemctl is-active wg-quick@wg0 2>&1 || true; " "systemctl list-units --type=service --state=running --no-pager | grep -iE 'otantik|wifi|wg|mabatis' || true", ), ( "NGINX", "nginx -t 2>&1; echo; ls -la /etc/nginx/sites-enabled/", ), ( "APP_ROOT", f"ls -la {APP_ROOT} 2>&1; echo; " f"ls -la {APP_ROOT}/system/autoload 2>&1; echo; " f"ls -la {APP_ROOT}/system/plugin 2>&1; echo; " f"stat -c '%y %n' {APP_ROOT}/config.php {APP_ROOT}/system/boot.php {APP_ROOT}/system/plugin/wifi_otantik.php 2>&1", ), ( "GIT_ON_SERVER", f"cd {APP_ROOT} && git status 2>&1 | head -20 || echo 'no git repo at {APP_ROOT}'", ), ( "OTHER_APPS_ON_BOX", "ls -la /var/www/ 2>&1; echo; ls -la /var/www/html/ 2>&1; echo; " "ls /home/otantik/apps 2>&1; echo; pm2 list 2>&1 || echo 'pm2 not found'", ), ( "DATABASE", "mysql -N -s -e \"SHOW DATABASES;\" 2>&1; echo; " "mysql -N -s wifi_otantik -e \"SELECT COUNT(*) FROM tbl_users;\" 2>&1; echo; " "mysql -N -s wifi_otantik -e \"SELECT setting,value FROM tbl_appconfig WHERE setting IN " "('CompanyName','currency_code','language','payment_gateway','otantik_domain','otantik_wg_server_public','otantik_commission');\" 2>&1", ), ( "WIREGUARD", "wg show 2>&1 || echo 'wg show failed (needs sudo? or not installed)'", ), ( "CRON", "crontab -l 2>&1; echo; sudo crontab -l 2>&1 || true", ), ( "HTTP_LOCAL_CHECKS", "curl -s -o /dev/null -w 'wifi.otantik.cm -> %{http_code}\\n' -H 'Host: wifi.otantik.cm' http://127.0.0.1/; " "curl -s -o /dev/null -w 'business.otantik.cm/connexion -> %{http_code}\\n' -H 'Host: business.otantik.cm' http://127.0.0.1/connexion; " "curl -s -o /dev/null -w 'portal.otantik.cm -> %{http_code}\\n' -H 'Host: portal.otantik.cm' http://127.0.0.1/; " "curl -sI https://wifi.otantik.cm/ | head -5; echo; " "curl -sI https://business.otantik.cm/connexion | head -5; echo; " "curl -sI https://portal.otantik.cm/ | head -5", ), ( "RECENT_ERRORS", "echo '--- nginx error log (last 30) ---'; tail -n 30 /var/log/nginx/wifi-otantik-error.log 2>/dev/null || tail -n 30 /var/log/nginx/error.log 2>/dev/null; " "echo; echo '--- php-fpm log (last 30) ---'; tail -n 30 /var/log/php8.3-fpm.log 2>/dev/null", ), ] def main() -> None: print(f"Connecting to {vps_ssh.USER}@{vps_ssh.HOST}:{vps_ssh.PORT} ...") code, out = vps_ssh.run("echo connected", timeout=30) if code != 0: print("FAILED TO CONNECT:", out) sys.exit(1) print("Connected OK.\n") for title, cmd in SECTIONS: print("=" * 70) print(title) print("=" * 70) try: code, out = vps_ssh.run(cmd, timeout=60) print(out.rstrip()) except Exception as e: # noqa: BLE001 print(f"[error running section: {e}]") print() print("=" * 70) print("DONE") print("=" * 70) if __name__ == "__main__": main()