import os import sys import time import paramiko HOST = "140.44.44.80" USER = "root" KEY_FILE = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet" def main(): print(f"Connecting to {USER}@{HOST}...") ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(HOST, username=USER, key_filename=KEY_FILE, timeout=10) print("Connected!") def run(cmd, check=True): print(f"\n>>> [RUN] {cmd}") stdin, stdout, stderr = ssh.exec_command(cmd) while not stdout.channel.exit_status_ready(): time.sleep(0.5) out = stdout.read().decode() err = stderr.read().decode() rc = stdout.channel.recv_exit_status() if out: print(out.strip()) if err and "warning" not in err.lower(): print(f"[STDERR] {err.strip()}", file=sys.stderr) if check and rc != 0: print(f"[FAIL] Exit code: {rc}", file=sys.stderr) return rc, out, err # 1. Create directories run("mkdir -p /opt/game-web/html") # 2. Write the python generator script py_script = '''#!/usr/bin/env python3 import json import subprocess import datetime import os import yaml GAMES = [ { "id": "valheim", "name": "Valheim", "tagline": "Viking Survival Craft (Crossplay)", "icon": "⚔️", "container": "gameseed-valheim", "ports": "2456 - 2457 UDP", "public_endpoint": "174.106.252.96:2456", "local_endpoint": "140.44.44.80:2456", "server_name": "SnarfNet Valheim Valhalla", "world_name": "Snarfheim", "password": "SnarfNet2026!", "save_path": "/opt/game-servers/valheim/worlds (NVMe)", "steam_app_id": "896660", }, { "id": "enshrouded", "name": "Enshrouded", "tagline": "Action RPG Survival", "icon": "🌲", "container": "gameseed-enshrouded", "ports": "15636 - 15637 UDP", "public_endpoint": "174.106.252.96:15636", "local_endpoint": "140.44.44.80:15636", "server_name": "SnarfNet Enshrouded Sanctuary", "world_name": "Sanctuary", "password": "SnarfNet2026!", "save_path": "/opt/game-servers/enshrouded/savegame (NVMe)", "steam_app_id": "2278520", }, { "id": "vrising", "name": "V Rising", "tagline": "Gothic Action RPG", "icon": "🧛", "container": "gameseed-vrising", "ports": "9876 - 9877 UDP", "public_endpoint": "174.106.252.96:9876", "local_endpoint": "140.44.44.80:9876", "server_name": "SnarfNet V Rising Vampire Lair", "world_name": "SnarfNet_Vampires", "password": "SnarfNet2026!", "save_path": "/opt/game-servers/vrising/Saves (NVMe)", "steam_app_id": "1829350", }, { "id": "stationeers", "name": "Stationeers", "tagline": "Hardcore Space Colonization", "icon": "🚀", "container": "gameseed-stationeers", "ports": "27015 - 27016 UDP", "public_endpoint": "174.106.252.96:27016", "local_endpoint": "140.44.44.80:27016", "server_name": "SnarfNet Stationeers Moonbase", "world_name": "Moon", "password": "SnarfNet2026!", "save_path": "/opt/game-servers/stationeers/saves (NVMe)", "steam_app_id": "600760", }, { "id": "fs25", "name": "Farming Simulator 25", "tagline": "Agriculture & Machinery Simulator", "icon": "🚜", "container": "gameseed-farming-simulator-25", "ports": "10823 TCP/UDP", "public_endpoint": "174.106.252.96:10823", "local_endpoint": "140.44.44.80:10823", "server_name": "SnarfNet FS25 Countryside", "world_name": "Countryside", "password": "SnarfNetAdmin2026!", "save_path": "/opt/game-servers/fs25/savegame (NVMe)", "steam_app_id": "2300320", } ] def get_container_status(container_name): cmd = ["docker", "inspect", container_name] res = subprocess.run(cmd, capture_output=True, text=True) if res.returncode != 0: return "shutdown", "Not Found", "Container not created" try: data = json.loads(res.stdout)[0] state = data.get("State", {}) status = state.get("Status", "unknown").lower() started_at = state.get("StartedAt", "") health = state.get("Health", {}).get("Status", "") if status == "running": if health == "unhealthy": return "error", "Unhealthy", "Container running but failing health checks" elif health == "starting": return "starting", "Starting", "Initializing container and game world" return "active", "Active / Online", f"Running since {started_at[:19].replace('T', ' ')}" elif status == "restarting": return "error", "Error / Restarting", "Container is crash-looping or awaiting assets" elif status == "exited": return "shutdown", "Shutdown", f"Exited (code {state.get('ExitCode')})" else: return status, status.capitalize(), f"State: {status}" except Exception as e: return "error", "Error", str(e) def get_host_metrics(): try: uptime = subprocess.check_output(["uptime", "-p"], text=True).strip() except Exception: uptime = "Up" try: mem_raw = subprocess.check_output(["free", "-m"], text=True).splitlines()[1].split() mem_total = round(int(mem_raw[1]) / 1024, 1) mem_used = round(int(mem_raw[2]) / 1024, 1) mem_str = f"{mem_used} GB / {mem_total} GB" except Exception: mem_str = "N/A" try: df_nvme = subprocess.check_output(["df", "-h", "/mnt/nvme-games"], text=True).splitlines()[1].split() disk_str = f"{df_nvme[2]} used / {df_nvme[1]} total ({df_nvme[3]} free)" except Exception: disk_str = "1 TB NVMe" return uptime, mem_str, disk_str def main(): now_str = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S EST") uptime, mem_str, disk_str = get_host_metrics() cards_html = "" active_count = 0 for g in GAMES: status_key, status_title, status_desc = get_container_status(g["container"]) if status_key == "active": active_count += 1 badge_class = "badge-active" dot_class = "dot-active" elif status_key == "starting": badge_class = "badge-starting" dot_class = "dot-starting" elif status_key == "error": badge_class = "badge-error" dot_class = "dot-error" else: badge_class = "badge-shutdown" dot_class = "dot-shutdown" cards_html += f"""
{g['public_endpoint']}
{g['local_endpoint']}