From 8b5b38c5c26feaf9343a25ce89697a9398324e28 Mon Sep 17 00:00:00 2001 From: Reditus <33814724+ReditusDraco@users.noreply.github.com> Date: Thu, 21 May 2026 02:47:10 +0100 Subject: [PATCH] Add launcher.bat for execution policy bypass, remove tracked scripts/, scrub real namespace from patch-battlegroup-example.sh --- README.md | 4 +- launcher.bat | 3 + scripts/db_check.py | 16 -- scripts/diagnostic.py | 256 --------------------------- scripts/patch-battlegroup-example.sh | 40 ----- 5 files changed, 6 insertions(+), 313 deletions(-) create mode 100644 launcher.bat delete mode 100644 scripts/db_check.py delete mode 100644 scripts/diagnostic.py delete mode 100644 scripts/patch-battlegroup-example.sh diff --git a/README.md b/README.md index a5cb0ba..9dadafb 100644 --- a/README.md +++ b/README.md @@ -21,11 +21,13 @@ If you're testing this project, grab builds from nightly for the latest features ## Quick Start ### Windows -1. Double-click `launcher.ps1` (or run `.\launcher.ps1` in PowerShell) +1. Double-click `launcher.bat` (or run `.\launcher.ps1` in PowerShell) 2. Select option **2** to run Setup on first use 3. Select option **1** to Start Dashboard > **Tip**: The launcher automatically finds your SSH key from the Dune Awakening server installation at `%LOCALAPPDATA%\DuneAwakeningServer\sshKey`. +> +> **Note**: If PowerShell blocks running scripts due to execution policy (`launcher.ps1` won't run), use `launcher.bat` instead — it bypasses the restriction automatically. You can also run `powershell.exe -ExecutionPolicy Bypass -File .\launcher.ps1` directly from Command Prompt. ## Features diff --git a/launcher.bat b/launcher.bat new file mode 100644 index 0000000..4e3121c --- /dev/null +++ b/launcher.bat @@ -0,0 +1,3 @@ +@echo off +powershell.exe -ExecutionPolicy Bypass -NoProfile -File "%~dp0launcher.ps1" +if %errorlevel% neq 0 pause diff --git a/scripts/db_check.py b/scripts/db_check.py deleted file mode 100644 index a6bff6e..0000000 --- a/scripts/db_check.py +++ /dev/null @@ -1,16 +0,0 @@ -import sys, psycopg2 -try: - host = 'localhost' - port = int(sys.argv[1]) - i = 2 - while i < len(sys.argv): - if sys.argv[i] == '-host' and i + 1 < len(sys.argv): - host = sys.argv[i + 1] - i += 2 - else: - i += 1 - c = psycopg2.connect(host=host, port=port, user='postgres', password='postgres', dbname='dune', connect_timeout=3) - c.close() - print('ok') -except: - pass \ No newline at end of file diff --git a/scripts/diagnostic.py b/scripts/diagnostic.py deleted file mode 100644 index 6b4b69a..0000000 --- a/scripts/diagnostic.py +++ /dev/null @@ -1,256 +0,0 @@ -"""Dune Dashboard Diagnostic Script - -Tests connectivity to all critical services: -- SSH to game server VM -- Database port-forward -- Director port-forward -- BGD pod status and logs -- RabbitMQ pods -- Kubernetes namespace access - -Usage: - python scripts/diagnostic.py [settings.yaml] -""" - -import sys -import os -import subprocess -import json - -try: - import yaml -except ImportError: - print("[ERROR] PyYAML not installed. Run: pip install pyyaml") - sys.exit(1) - - -def load_settings(path): - with open(path) as f: - return yaml.safe_load(f) - - -def run_cmd(cmd, timeout=15): - try: - result = subprocess.run( - cmd, shell=True, capture_output=True, text=True, timeout=timeout - ) - return result.returncode, result.stdout.strip(), result.stderr.strip() - except subprocess.TimeoutExpired: - return -1, "", "Command timed out" - except Exception as e: - return -1, "", str(e) - - -def check_ssh(settings): - print("\n[1/6] Checking SSH connection...") - host = settings['server']['host'] - ssh_key = os.path.expandvars(settings['server'].get('ssh_key', '')) - ssh_user = settings['server'].get('ssh_user', 'dune') - - rc, out, err = run_cmd( - f'ssh -i "{ssh_key}" -o StrictHostKeyChecking=no -o ConnectTimeout=10 -o BatchMode=yes {ssh_user}@{host} "echo OK"', - timeout=15 - ) - if rc == 0 and 'OK' in out: - print(" [OK] SSH connection successful") - return True - else: - print(f" [FAIL] SSH failed: {err or out}") - return False - - -def check_namespace(settings): - print("\n[2/6] Checking Kubernetes namespace...") - ns = settings.get('kubernetes', {}).get('namespace', '') - if not ns: - print(" [FAIL] Kubernetes namespace not set in settings.yaml") - return False - - host = settings['server']['host'] - ssh_key = os.path.expandvars(settings['server'].get('ssh_key', '')) - ssh_user = settings['server'].get('ssh_user', 'dune') - - rc, out, err = run_cmd( - f'ssh -i "{ssh_key}" -o StrictHostKeyChecking=no -o ConnectTimeout=10 {ssh_user}@{host} "sudo kubectl get namespace {ns}"', - timeout=15 - ) - if rc == 0 and ns in out: - print(f" [OK] Namespace '{ns}' exists") - return True - else: - print(f" [FAIL] Namespace '{ns}' not found: {err or out}") - return False - - -def check_db_port_forward(settings): - print("\n[3/6] Checking database port-forward...") - port = settings.get('server', {}).get('port', 15432) - - import socket - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.settimeout(3) - try: - sock.connect(('127.0.0.1', port)) - sock.close() - print(f" [OK] Database port-forward listening on localhost:{port}") - return True - except Exception: - print("") - print("+----------------------------------------------------------+") - print("| [FAIL] Database port-forward not connected |") - print("| |") - print("| *** THIS IS NOT CRITICAL *** |") - print("| The database port-forward requires the launcher to be |") - print("| running. If you're just running diagnostics standalone, |") - print("| this will fail. Start the launcher first - it sets up |") - print("| the SSH tunnel and port-forwards automatically. |") - print("+----------------------------------------------------------+") - print("") - return False - - -def check_director_port_forward(settings): - print("\n[4/6] Checking director port-forward...") - port = settings.get('director', {}).get('port', 32479) - - import socket - sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - sock.settimeout(3) - try: - sock.connect(('127.0.0.1', port)) - sock.close() - print(f" [OK] Director port-forward listening on localhost:{port}") - - import urllib.request - try: - r = urllib.request.urlopen(f'http://127.0.0.1:{port}/v0/battlegroup', timeout=5) - data = json.loads(r.read()) - print(f" [OK] Director API responding (battlegroup loaded)") - return True - except Exception as e: - print(f" [WARN] Director port open but API not responding: {e}") - print(" The BGD pod may be starting or have internal errors") - return False - except Exception: - print(f" [FAIL] Cannot connect to localhost:{port}") - print(" NOTE: This is expected if the launcher hasn't started yet.") - print(" Run the launcher and these will connect automatically.") - return False - - -def check_bgd_pod(settings): - print("\n[5/6] Checking BGD pod status...") - host = settings['server']['host'] - ssh_key = os.path.expandvars(settings['server'].get('ssh_key', '')) - ssh_user = settings['server'].get('ssh_user', 'dune') - ns = settings.get('kubernetes', {}).get('namespace', '') - - rc, out, err = run_cmd( - f'ssh -i "{ssh_key}" -o StrictHostKeyChecking=no -o ConnectTimeout=10 {ssh_user}@{host} "sudo kubectl get pods -n {ns} | grep bgd"', - timeout=15 - ) - if not out: - print(" [FAIL] No BGD pod found") - print(" The battlegroup director deployment may be scaled to 0") - return False - - for line in out.split('\n'): - parts = line.split() - if len(parts) >= 3: - name = parts[0] - ready = parts[1] - status = parts[2] - if 'Running' in status and '1/1' in ready: - print(f" [OK] BGD pod running: {name} (ready={ready})") - else: - print(f" [WARN] BGD pod issue: {name} (ready={ready}, status={status})") - - if 'CrashLoopBackOff' in out: - print("\n BGD pod is crash looping. Checking recent logs:") - rc, logs, _ = run_cmd( - f'ssh -i "{ssh_key}" -o StrictHostKeyChecking=no -o ConnectTimeout=10 {ssh_user}@{host} "sudo kubectl logs -n {ns} -l app={ns}-bgd-deploy --tail=20"', - timeout=30 - ) - if logs: - for line in logs.split('\n')[-10:]: - print(f" {line}") - - return 'Running' in out - - -def check_rabbitmq(settings): - print("\n[6/6] Checking RabbitMQ pods...") - host = settings['server']['host'] - ssh_key = os.path.expandvars(settings['server'].get('ssh_key', '')) - ssh_user = settings['server'].get('ssh_user', 'dune') - ns = settings.get('kubernetes', {}).get('namespace', '') - - rc, out, err = run_cmd( - f'ssh -i "{ssh_key}" -o StrictHostKeyChecking=no -o ConnectTimeout=10 {ssh_user}@{host} "sudo kubectl get pods -n {ns} | grep mq"', - timeout=15 - ) - if not out: - print(" [FAIL] No RabbitMQ pods found") - return False - - all_ok = True - for line in out.split('\n'): - parts = line.split() - if len(parts) >= 3: - name = parts[0] - ready = parts[1] - status = parts[2] - if 'Running' in status: - print(f" [OK] RabbitMQ running: {name} (ready={ready})") - else: - print(f" [WARN] RabbitMQ issue: {name} (ready={ready}, status={status})") - all_ok = False - - return all_ok - - -def main(): - settings_path = sys.argv[1] if len(sys.argv) > 1 else 'settings.yaml' - if not os.path.exists(settings_path): - print(f"[ERROR] Settings file not found: {settings_path}") - sys.exit(1) - - print("=" * 60) - print(" Dune Awakening Dashboard - Diagnostic Tool") - print("=" * 60) - - settings = load_settings(settings_path) - - results = [] - results.append(("SSH Connection", check_ssh(settings))) - results.append(("Kubernetes Namespace", check_namespace(settings))) - results.append(("Database Port-Forward", check_db_port_forward(settings))) - results.append(("Director Port-Forward", check_director_port_forward(settings))) - results.append(("BGD Pod", check_bgd_pod(settings))) - results.append(("RabbitMQ", check_rabbitmq(settings))) - - print("\n" + "=" * 60) - print(" Summary") - print("=" * 60) - - passed = sum(1 for _, ok in results if ok) - total = len(results) - - for name, ok in results: - status = "[OK]" if ok else "[FAIL]" - print(f" {status} {name}") - - print(f"\n {passed}/{total} checks passed") - - if passed < total: - print("\n Troubleshooting tips:") - print(" - Restart the launcher to re-establish port-forwards") - print(" - Check BGD logs: sudo kubectl logs -n -l app=-bgd-deploy --tail=50") - print(" - If RabbitMQ auth fails, try restarting the full battlegroup") - print(" - Run the launcher with verbose output for more details") - - sys.exit(0 if passed == total else 1) - - -if __name__ == '__main__': - main() diff --git a/scripts/patch-battlegroup-example.sh b/scripts/patch-battlegroup-example.sh deleted file mode 100644 index 6442c56..0000000 --- a/scripts/patch-battlegroup-example.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -BG_NAME="sh-b17a5f036d1f7882-bzhczd" -NAMESPACE="funcom-seabass-sh-b17a5f036d1f7882-bzhczd" - -echo "Patching battlegroup: $BG_NAME" - -sudo kubectl patch battlegroup "$BG_NAME" -n "$NAMESPACE" --type=merge -p '{ - "spec": { - "serverGroup": { - "template": { - "spec": { - "sets": [ - { - "map": "DeepDesert_1", - "partitions": [8, 30], - "replicas": 2, - "resources": { - "limits": { - "memory": "15Gi" - } - }, - "arguments": [ - "-FarmRegion=North America Test", - "-RMQGameTlsEnabled=true" - ] - } - ] - } - } - } - } -}' - -if [ $? -eq 0 ]; then - echo "Patch applied successfully" -else - echo "Failed to apply patch" - exit 1 -fi \ No newline at end of file