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 <noreply@anthropic.com>
This commit is contained in:
parent
bcda9a9193
commit
2950bc9b2f
@ -502,27 +502,33 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
|
|
||||||
get_appstore_apps)
|
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"
|
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
|
if [ -f "$CATALOG_FILE" ]; then
|
||||||
jq --arg installed_pkgs "$INSTALLED_PKGS" '
|
# Get modules list with installation status from secubox-appstore
|
||||||
{
|
MODULES_JSON=$(/usr/sbin/secubox-appstore list --json 2>/dev/null)
|
||||||
apps: [.plugins[] | . + {
|
|
||||||
installed: (
|
if [ -n "$MODULES_JSON" ]; then
|
||||||
if .packages.required[0] then
|
# Merge installation status from modules into catalog apps
|
||||||
($installed_pkgs | split("\n") | index(.packages.required[0])) != null
|
jq --argjson modules "$MODULES_JSON" '
|
||||||
else
|
{
|
||||||
false
|
apps: [.plugins[] | . as $app |
|
||||||
end
|
($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),
|
||||||
categories: .categories
|
enabled: (if $mod then ($mod.enabled // false) else false end),
|
||||||
}
|
status: (if $mod then ($mod.status // "unknown") else "not_installed" end)
|
||||||
' "$CATALOG_FILE"
|
}
|
||||||
|
],
|
||||||
|
categories: .categories
|
||||||
|
}
|
||||||
|
' "$CATALOG_FILE"
|
||||||
|
else
|
||||||
|
# Fallback: just return catalog without status
|
||||||
|
jq '{apps: .plugins, categories: .categories}' "$CATALOG_FILE"
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
echo '{"apps":[],"categories":{}}'
|
echo '{"apps":[],"categories":{}}'
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user