#!/usr/bin/env python3 import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) import vps_ssh root = Path(r"c:\laragon\www\light-otantik-nux\deploy\saas\nux-custom") remote = "/var/www/wifi-otantik" files = ["system/plugin/wifi_otantik.php"] for rel in files: local = root / rel data = local.read_bytes().replace(b"\r\n", b"\n") tmp = Path(__file__).resolve().parent / ("_t_" + Path(rel).name) tmp.write_bytes(data) remote_tmp = "/tmp/wo-" + Path(rel).name.replace(".", "-") vps_ssh.put(str(tmp), remote_tmp) tmp.unlink(missing_ok=True) print("uploaded", rel) code, out = vps_ssh.run( f"install -m 644 /tmp/wo-wifi_otantik-php {remote}/system/plugin/wifi_otantik.php && " f"rm -rf {remote}/ui/compiled/* {remote}/system/cache/* 2>/dev/null; " "sudo systemctl reload php8.2-fpm 2>/dev/null || sudo systemctl reload php-fpm 2>/dev/null || true", sudo=True, ) print(code, out[-1500:] if out else "")