From 051d10de127c3542866d7d2bd065c46b3c0f4f91 Mon Sep 17 00:00:00 2001 From: CyberMind-FR Date: Fri, 26 Dec 2025 07:59:57 +0100 Subject: [PATCH] fix(secubox): read modules from UCI config instead of RPCD detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed empty modules page by changing all module iteration to use UCI config instead of RPCD script detection: Problem: - $MODULES was populated by detect_modules() which only returned modules with installed RPCD scripts - When only luci-app-secubox is installed (without individual modules), $MODULES was empty - This caused modules page to show no modules Solution: - Changed all functions to iterate through UCI config sections - Uses: uci show secubox | grep "=module$" - Now shows ALL modules defined in /etc/config/secubox - Modules are marked as installed/not installed based on opkg Functions updated: - get_modules() - get_modules_by_category() - get_dashboard_data() - get_alerts() - get_health() - get_diagnostics() This allows the modules page to display all available SecuBox modules even when they're not installed yet. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- .../root/usr/libexec/rpcd/luci.secubox | 84 +++++++++++-------- 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/luci-app-secubox/root/usr/libexec/rpcd/luci.secubox b/luci-app-secubox/root/usr/libexec/rpcd/luci.secubox index a3107e39..d46a0288 100755 --- a/luci-app-secubox/root/usr/libexec/rpcd/luci.secubox +++ b/luci-app-secubox/root/usr/libexec/rpcd/luci.secubox @@ -128,12 +128,15 @@ get_status() { get_modules() { json_init json_add_array "modules" - - config_load secubox - - for module in $MODULES; do + + config_load secubox 2>/dev/null || true + + # List all module sections from UCI config + local module_sections=$(uci -q show secubox | grep "=module$" | cut -d. -f2 | cut -d= -f1) + + for module in $module_sections; do local name desc category icon color package config - + config_get name "$module" name "$module" config_get desc "$module" description "" config_get category "$module" category "other" @@ -141,10 +144,10 @@ get_modules() { config_get color "$module" color "#64748b" config_get package "$module" package "" config_get config "$module" config "" - + local is_installed=$(check_module_installed "$module") local is_running=$(check_module_running "$module") - + json_add_object "" json_add_string "id" "$module" json_add_string "name" "$name" @@ -158,7 +161,7 @@ get_modules() { json_add_boolean "running" "$is_running" json_close_object done - + json_close_array json_dump } @@ -166,29 +169,32 @@ get_modules() { # Get modules by category get_modules_by_category() { local category="$1" - + json_init json_add_array "modules" - - config_load secubox - - for module in $MODULES; do + + config_load secubox 2>/dev/null || true + + # List all module sections from UCI config + local module_sections=$(uci -q show secubox | grep "=module$" | cut -d. -f2 | cut -d= -f1) + + for module in $module_sections; do local mod_category config_get mod_category "$module" category "other" - + if [ "$mod_category" = "$category" ]; then local name desc icon color package config - + config_get name "$module" name "$module" config_get desc "$module" description "" config_get icon "$module" icon "box" config_get color "$module" color "#64748b" config_get package "$module" package "" config_get config "$module" config "" - + local is_installed=$(check_module_installed "$module") local is_running=$(check_module_running "$module") - + json_add_object "" json_add_string "id" "$module" json_add_string "name" "$name" @@ -200,7 +206,7 @@ get_modules_by_category() { json_close_object fi done - + json_close_array json_dump } @@ -308,26 +314,30 @@ restart_module() { get_health() { json_init json_add_array "checks" - + + config_load secubox 2>/dev/null || true + + # List all module sections from UCI config + local module_sections=$(uci -q show secubox | grep "=module$" | cut -d. -f2 | cut -d= -f1) + # Check each installed module - for module in $MODULES; do + for module in $module_sections; do local is_installed=$(check_module_installed "$module") - + if [ "$is_installed" = "1" ]; then local is_running=$(check_module_running "$module") local name - - config_load secubox + config_get name "$module" name "$module" - + local status="ok" local message="Running normally" - + if [ "$is_running" != "1" ]; then status="warning" message="Service not running" fi - + json_add_object "" json_add_string "module" "$module" json_add_string "name" "$name" @@ -336,16 +346,16 @@ get_health() { json_close_object fi done - + json_close_array - + # Overall health local overall="healthy" # Could add more sophisticated health checks here - + json_add_string "overall" "$overall" json_add_int "timestamp" "$(date +%s)" - + json_dump } @@ -364,7 +374,9 @@ get_diagnostics() { # Modules status json_add_array "modules" - for module in $MODULES; do + config_load secubox 2>/dev/null || true + local module_sections=$(uci -q show secubox | grep "=module$" | cut -d. -f2 | cut -d= -f1) + for module in $module_sections; do local is_installed=$(check_module_installed "$module") local is_running=$(check_module_running "$module") @@ -478,7 +490,10 @@ get_alerts() { # Check each installed module for alerts config_load secubox 2>/dev/null || true - for module in $MODULES; do + # List all module sections from UCI config + local module_sections=$(uci -q show secubox | grep "=module$" | cut -d. -f2 | cut -d= -f1) + + for module in $module_sections; do local is_installed=$(check_module_installed "$module") if [ "$is_installed" = "1" ]; then @@ -591,7 +606,10 @@ get_dashboard_data() { json_add_array "modules" local total=0 installed=0 running=0 - for module in $MODULES; do + # List all module sections from UCI config + local module_sections=$(uci -q show secubox | grep "=module$" | cut -d. -f2 | cut -d= -f1) + + for module in $module_sections; do local name desc category icon color config_get name "$module" name "$module" config_get desc "$module" description ""