From 2950bc9b2f8969b6651335f78e8bce03d9df2383 Mon Sep 17 00:00:00 2001 From: CyberMind-FR Date: Fri, 9 Jan 2026 16:57:03 +0100 Subject: [PATCH] fix: Use secubox-appstore for app installation status in appstore Instead of trying to parse opkg output directly, use the same secubox-appstore list --json command that the modules page uses. This ensures consistent installation detection across both views. The get_appstore_apps method now: 1. Gets modules list from secubox-appstore (which properly detects installed packages) 2. Merges installation status into catalog apps 3. Returns apps with correct installed/enabled/status fields Co-Authored-By: Claude Opus 4.5 --- .../root/usr/libexec/rpcd/luci.secubox | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/package/secubox/secubox-core/root/usr/libexec/rpcd/luci.secubox b/package/secubox/secubox-core/root/usr/libexec/rpcd/luci.secubox index fe8d6b25..a91dc15a 100755 --- a/package/secubox/secubox-core/root/usr/libexec/rpcd/luci.secubox +++ b/package/secubox/secubox-core/root/usr/libexec/rpcd/luci.secubox @@ -502,27 +502,33 @@ case "$1" in ;; get_appstore_apps) - # Return apps from main catalog with categories and installation status + # Return apps from catalog with installation status + # Use secubox-appstore which properly detects installed packages CATALOG_FILE="/usr/share/secubox/catalog.json" - if [ -f "$CATALOG_FILE" ]; then - # Get installed packages list once for efficiency - INSTALLED_PKGS=$(opkg list-installed 2>/dev/null | awk '{print $1}') - # Process catalog and add installed status to each app - jq --arg installed_pkgs "$INSTALLED_PKGS" ' - { - apps: [.plugins[] | . + { - installed: ( - if .packages.required[0] then - ($installed_pkgs | split("\n") | index(.packages.required[0])) != null - else - false - end - ) - }], - categories: .categories - } - ' "$CATALOG_FILE" + if [ -f "$CATALOG_FILE" ]; then + # Get modules list with installation status from secubox-appstore + MODULES_JSON=$(/usr/sbin/secubox-appstore list --json 2>/dev/null) + + if [ -n "$MODULES_JSON" ]; then + # Merge installation status from modules into catalog apps + jq --argjson modules "$MODULES_JSON" ' + { + apps: [.plugins[] | . as $app | + ($modules.modules // [] | map(select(.id == $app.id or .name == $app.id)) | first) as $mod | + $app + { + installed: (if $mod then ($mod.installed // false) else false end), + enabled: (if $mod then ($mod.enabled // false) else false end), + status: (if $mod then ($mod.status // "unknown") else "not_installed" end) + } + ], + categories: .categories + } + ' "$CATALOG_FILE" + else + # Fallback: just return catalog without status + jq '{apps: .plugins, categories: .categories}' "$CATALOG_FILE" + fi else echo '{"apps":[],"categories":{}}' fi