fix(secubox): read modules from UCI config instead of RPCD detection
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 <noreply@anthropic.com>
This commit is contained in:
parent
03dbed83c9
commit
051d10de12
@ -129,9 +129,12 @@ get_modules() {
|
|||||||
json_init
|
json_init
|
||||||
json_add_array "modules"
|
json_add_array "modules"
|
||||||
|
|
||||||
config_load secubox
|
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 name desc category icon color package config
|
local name desc category icon color package config
|
||||||
|
|
||||||
config_get name "$module" name "$module"
|
config_get name "$module" name "$module"
|
||||||
@ -170,9 +173,12 @@ get_modules_by_category() {
|
|||||||
json_init
|
json_init
|
||||||
json_add_array "modules"
|
json_add_array "modules"
|
||||||
|
|
||||||
config_load secubox
|
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 mod_category
|
local mod_category
|
||||||
config_get mod_category "$module" category "other"
|
config_get mod_category "$module" category "other"
|
||||||
|
|
||||||
@ -309,15 +315,19 @@ get_health() {
|
|||||||
json_init
|
json_init
|
||||||
json_add_array "checks"
|
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
|
# Check each installed module
|
||||||
for module in $MODULES; do
|
for module in $module_sections; do
|
||||||
local is_installed=$(check_module_installed "$module")
|
local is_installed=$(check_module_installed "$module")
|
||||||
|
|
||||||
if [ "$is_installed" = "1" ]; then
|
if [ "$is_installed" = "1" ]; then
|
||||||
local is_running=$(check_module_running "$module")
|
local is_running=$(check_module_running "$module")
|
||||||
local name
|
local name
|
||||||
|
|
||||||
config_load secubox
|
|
||||||
config_get name "$module" name "$module"
|
config_get name "$module" name "$module"
|
||||||
|
|
||||||
local status="ok"
|
local status="ok"
|
||||||
@ -364,7 +374,9 @@ get_diagnostics() {
|
|||||||
|
|
||||||
# Modules status
|
# Modules status
|
||||||
json_add_array "modules"
|
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_installed=$(check_module_installed "$module")
|
||||||
local is_running=$(check_module_running "$module")
|
local is_running=$(check_module_running "$module")
|
||||||
|
|
||||||
@ -478,7 +490,10 @@ get_alerts() {
|
|||||||
# Check each installed module for alerts
|
# Check each installed module for alerts
|
||||||
config_load secubox 2>/dev/null || true
|
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")
|
local is_installed=$(check_module_installed "$module")
|
||||||
|
|
||||||
if [ "$is_installed" = "1" ]; then
|
if [ "$is_installed" = "1" ]; then
|
||||||
@ -591,7 +606,10 @@ get_dashboard_data() {
|
|||||||
json_add_array "modules"
|
json_add_array "modules"
|
||||||
local total=0 installed=0 running=0
|
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
|
local name desc category icon color
|
||||||
config_get name "$module" name "$module"
|
config_get name "$module" name "$module"
|
||||||
config_get desc "$module" description ""
|
config_get desc "$module" description ""
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user