From b1a5621a0a52c604ff1ac3ab4efdb53876520219 Mon Sep 17 00:00:00 2001 From: Yellowcooln <12516003+yellowcooln@users.noreply.github.com> Date: Thu, 23 Apr 2026 21:46:13 -0400 Subject: [PATCH] Revert "Honor seeded Buildroot setup config" This reverts commit aba0f5bd092c9b7becc6997a75629b84533dafb5. --- buildroot-manage.sh | 1 - config.yaml.example | 3 --- repeater/web/api_endpoints.py | 31 +++++++------------------------ repeater/web/auth_endpoints.py | 16 ++-------------- 4 files changed, 9 insertions(+), 42 deletions(-) diff --git a/buildroot-manage.sh b/buildroot-manage.sh index 2eb1066..102edfc 100644 --- a/buildroot-manage.sh +++ b/buildroot-manage.sh @@ -776,7 +776,6 @@ security = repeater.setdefault("security", {}) radio = data.setdefault("radio", {}) repeater["node_name"] = node_name -repeater["setup_complete"] = True security["admin_password"] = admin_password security["jwt_secret"] = jwt_secret diff --git a/config.yaml.example b/config.yaml.example index 9336dc5..1060e7b 100644 --- a/config.yaml.example +++ b/config.yaml.example @@ -6,9 +6,6 @@ repeater: # Node name for logging and identification node_name: "mesh-repeater-01" - # Set true once initial provisioning is complete so the web UI can skip /setup - setup_complete: false - # TX mode: forward | monitor | no_tx (default: forward) # forward = repeat on; monitor = no repeat but companions/tenants can send; no_tx = all TX off # mode: forward diff --git a/repeater/web/api_endpoints.py b/repeater/web/api_endpoints.py index a98d3e2..4776038 100644 --- a/repeater/web/api_endpoints.py +++ b/repeater/web/api_endpoints.py @@ -7,7 +7,6 @@ from pathlib import Path from typing import Callable, Optional import cherrypy -import yaml from pymc_core.protocol import CryptoUtils from repeater import __version__ @@ -197,14 +196,6 @@ class APIEndpoints: def _is_cors_enabled(self): return self.config.get("web", {}).get("cors_enabled", False) - def _load_live_config(self): - """Prefer the on-disk config when checking first-boot/setup state.""" - try: - with open(self._config_path, "r", encoding="utf-8") as f: - return yaml.safe_load(f) or {} - except Exception: - return self.config or {} - def _set_cors_headers(self): if self._is_cors_enabled(): cherrypy.response.headers["Access-Control-Allow-Origin"] = "*" @@ -311,27 +302,24 @@ class APIEndpoints: def needs_setup(self): """Check if the repeater needs initial setup configuration""" try: - config = self._load_live_config() + config = self.config # Check for default values that indicate first-time setup - repeater_config = config.get("repeater", {}) - node_name = repeater_config.get("node_name", "") + node_name = config.get("repeater", {}).get("node_name", "") has_default_name = node_name in ["mesh-repeater-01", ""] - admin_password = repeater_config.get("security", {}).get("admin_password", "") - has_default_password = admin_password in ["admin123", ""] - setup_complete = bool(repeater_config.get("setup_complete", False)) - - needs_setup = (has_default_name or has_default_password) and not ( - setup_complete and not has_default_name and not has_default_password + admin_password = ( + config.get("repeater", {}).get("security", {}).get("admin_password", "") ) + has_default_password = admin_password in ["admin123", ""] + + needs_setup = has_default_name or has_default_password return { "needs_setup": needs_setup, "reasons": { "default_name": has_default_name, "default_password": has_default_password, - "setup_complete": setup_complete, }, } except Exception as e: @@ -490,7 +478,6 @@ class APIEndpoints: if "repeater" not in config_yaml: config_yaml["repeater"] = {} config_yaml["repeater"]["node_name"] = node_name - config_yaml["repeater"]["setup_complete"] = True if "security" not in config_yaml["repeater"]: config_yaml["repeater"]["security"] = {} @@ -574,10 +561,6 @@ class APIEndpoints: with open(self._config_path, "w") as f: yaml.dump(config_yaml, f, default_flow_style=False, sort_keys=False) - # Keep in-memory config aligned until the restart lands. - self.config.clear() - self.config.update(config_yaml) - logger.info( f"Setup wizard completed: node_name={node_name}, hardware={hardware_key}, freq={freq_mhz}MHz" ) diff --git a/repeater/web/auth_endpoints.py b/repeater/web/auth_endpoints.py index 8361035..2ceb572 100644 --- a/repeater/web/auth_endpoints.py +++ b/repeater/web/auth_endpoints.py @@ -3,7 +3,6 @@ Authentication endpoints for login and token management """ import cherrypy import logging -import yaml from .auth.middleware import require_auth logger = logging.getLogger(__name__) @@ -153,16 +152,6 @@ class AuthEndpoints: self.jwt_handler = jwt_handler self.token_manager = token_manager self.config_manager = config_manager - - def _load_live_config(self): - config_path = getattr(self.config_manager, "config_path", None) - if not config_path: - return self.config - try: - with open(config_path, "r", encoding="utf-8") as f: - return yaml.safe_load(f) or {} - except Exception: - return self.config @cherrypy.expose def login(self, **kwargs): @@ -196,8 +185,7 @@ class AuthEndpoints: # Validate credentials against config # Check if username is 'admin' and password matches config - live_config = self._load_live_config() - repeater_config = live_config.get('repeater', {}) + repeater_config = self.config.get('repeater', {}) security_config = repeater_config.get('security', {}) config_password = security_config.get('admin_password', '') @@ -472,4 +460,4 @@ class AuthEndpoints: return json.dumps({ 'success': False, 'error': 'Failed to change password' - }).encode('utf-8') + }).encode('utf-8') \ No newline at end of file