Major feature release implementing comprehensive state management, component registry, and admin control center with full UI integration. ## Backend Features (secubox-core v0.9.0-1) State Management System: - ✅ State database (state-db.json) with 15 states across 4 categories - ✅ State machine with transition matrix validation - ✅ secubox-state CLI (8 commands: get, set, history, list, validate, sync, freeze, clear-error) - ✅ state-machine.sh with atomic transitions using flock - ✅ State history tracking with timestamps and reasons - ✅ Error state handling with detailed error info - ✅ Frozen state support for system-critical components Component Registry System: - ✅ Component registry database (component-registry.json) - ✅ secubox-component CLI (7 commands: list, get, register, unregister, tree, affected, set-setting) - ✅ Component types: app, module, widget, service, composite - ✅ Dependency tracking (required/optional) - ✅ Recursive dependency tree resolution - ✅ Reverse dependency tracking - ✅ Component settings management - ✅ Profile tagging and filtering Auto-Sync System: - ✅ secubox-sync-registry CLI for catalog synchronization - ✅ Auto-populate from catalog.json - ✅ Plugin catalog directory scanning - ✅ Installed package detection - ✅ Automatic state initialization RPC Backend (luci.secubox): - ✅ 6 state management RPC methods - ✅ 5 component registry RPC methods - ✅ Bulk operations support - ✅ State validation endpoints ## Frontend Features (luci-app-secubox-admin v1.0.0-16) UI Components: - ✅ state-utils.js: 20+ utility functions, state config, transition validation - ✅ StateIndicator.js: 5 rendering modes (badge, compact, pill, dot, statistics) - ✅ StateTimeline.js: 4 visualization modes (vertical, horizontal, compact, transition diagram) - ✅ state-management.css: 600+ lines with animations, responsive design, accessibility Admin Control Center Dashboard: - ✅ System overview panel with health metrics - ✅ Component state summary with statistics - ✅ Recent state transitions timeline - ✅ Alerts panel for warnings and errors - ✅ Quick actions panel - ✅ Real-time updates (5-second polling) - ✅ Metric cards with hover effects - ✅ State distribution by category API Integration (api.js): - ✅ 11 RPC method declarations - ✅ Enhanced methods: getComponentWithState(), getAllComponentsWithStates() - ✅ Bulk operations: bulkSetComponentState() - ✅ State statistics: getStateStatistics() - ✅ Retry logic with exponential backoff - ✅ Promise-based async operations ## Documentation Comprehensive Documentation: - ✅ API-REFERENCE.md (1,200+ lines): Complete API docs for RPC, CLI, JS - ✅ EXAMPLES.md (800+ lines): 30+ usage examples, shell scripts, integration patterns - ✅ State definitions table (15 states) - ✅ State transition matrix - ✅ Component metadata schemas - ✅ Error codes reference - ✅ Testing examples ## State Definitions 15 States Across 4 Categories: - Persistent: available, installed, active, disabled, frozen - Transient: installing, configuring, activating, starting, stopping, uninstalling - Runtime: running, stopped - Error: error (with subtypes) State Transition Flow: available → installing → installed → configuring → configured → activating → active → starting → running → stopping → stopped ## Technical Details Files Created (10 backend + 8 frontend): Backend: - /usr/sbin/secubox-state (12KB, 8 commands) - /usr/sbin/secubox-component (12KB, 7 commands) - /usr/sbin/secubox-sync-registry (8.4KB) - /usr/share/secubox/state-machine.sh (5.2KB) - /var/lib/secubox/state-db.json (schema) - /var/lib/secubox/component-registry.json (schema) Frontend: - resources/secubox-admin/state-utils.js (~400 lines) - resources/secubox-admin/components/StateIndicator.js (~350 lines) - resources/secubox-admin/components/StateTimeline.js (~450 lines) - resources/secubox-admin/state-management.css (~600 lines) - resources/view/secubox-admin/control-center.js (~550 lines) - resources/secubox-admin/api.js (+145 lines) Documentation: - docs/admin-control-center/API-REFERENCE.md (1,200+ lines) - docs/admin-control-center/EXAMPLES.md (800+ lines) Files Modified (3): - package/secubox/secubox-core/Makefile (v0.8.0 → v0.9.0-1) - package/secubox/luci-app-secubox-admin/Makefile (release 15 → 16) - package/secubox/secubox-core/root/usr/libexec/rpcd/luci.secubox (+157 lines) ## Installation & Migration Makefile Updates: - Added 3 new CLI tools to install section - Added state-machine.sh to scripts - Updated package description - Enhanced postinst to initialize databases - Auto-sync registry on first install Postinst Features: - Automatic state-db.json initialization - Automatic component-registry.json initialization - Catalog sync on install - Version announcement with new features ## Performance & Security Performance: - File locking (flock) for atomic state transitions - State history limited to 100 entries per component - RPC retry logic with exponential backoff - Bulk operations use Promise.all for parallel execution - Component list caching (30 seconds) Security: - Frozen state prevents unauthorized modifications - All state changes logged with timestamp and reason - System-critical components have additional safeguards - Proper authentication required for state transitions ## Testing & Validation Features: - State transition validation - Component dependency resolution - Circular dependency detection - State consistency checker - Integration test scripts included in docs ## Breaking Changes None - Backward Compatible: - Existing RPC methods remain functional - State-aware methods are additive - Components without state default to 'available' - Migration is automatic on install ## Statistics Total Implementation: - Lines of Code: ~4,000 - Backend: ~1,800 (Bash + JSON) - Frontend: ~2,200 (JavaScript + CSS) - Documentation: ~2,000 (Markdown) - Functions/Commands: 40+ - RPC Methods: 11 - CLI Commands: 22 - UI Components: 5 - Documentation Pages: 2 ## Next Phase Remaining from Plan: - Phase 4: System Hub integration - Phase 5: Migration script (secubox-migrate-state) - Phase 6: Additional documentation (ARCHITECTURE.md, STATE-MANAGEMENT.md, etc.) - Phase 7: Additional UI views (components.js, state-manager.js, debug-panel.js) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
159 lines
4.8 KiB
Makefile
159 lines
4.8 KiB
Makefile
#
|
|
# SecuBox Core - Modular Framework Foundation
|
|
#
|
|
|
|
include $(TOPDIR)/rules.mk
|
|
|
|
PKG_NAME:=secubox-core
|
|
PKG_VERSION:=0.9.0
|
|
PKG_RELEASE:=1
|
|
PKG_ARCH:=all
|
|
PKG_LICENSE:=GPL-2.0
|
|
PKG_MAINTAINER:=SecuBox Team
|
|
|
|
include $(INCLUDE_DIR)/package.mk
|
|
|
|
define Package/secubox-core
|
|
SECTION:=admin
|
|
CATEGORY:=Administration
|
|
TITLE:=SecuBox Core Framework
|
|
DEPENDS:=+libubox +libubus +libuci +rpcd +bash +coreutils-base64 +jsonfilter +jq
|
|
PKGARCH:=all
|
|
endef
|
|
|
|
define Package/secubox-core/description
|
|
SecuBox Core Framework provides the foundational infrastructure for the
|
|
modular SecuBox system including:
|
|
- Module/AppStore management
|
|
- Component state management system
|
|
- Component registry and dependency tracking
|
|
- Profile and template engine
|
|
- Diagnostics and health checks
|
|
- Unified CLI interface
|
|
- ubus RPC backend
|
|
endef
|
|
|
|
define Package/secubox-core/conffiles
|
|
/etc/config/secubox
|
|
/etc/config/secubox-appstore
|
|
/etc/secubox/profiles/
|
|
/etc/secubox/templates/
|
|
/etc/secubox/macros/
|
|
endef
|
|
|
|
define Build/Compile
|
|
endef
|
|
|
|
define Package/secubox-core/install
|
|
$(INSTALL_DIR) $(1)/etc/config
|
|
$(INSTALL_CONF) ./root/etc/config/secubox $(1)/etc/config/
|
|
$(INSTALL_CONF) ./root/etc/config/secubox-appstore $(1)/etc/config/
|
|
|
|
$(INSTALL_DIR) $(1)/etc/init.d
|
|
$(INSTALL_BIN) ./root/etc/init.d/secubox-core $(1)/etc/init.d/
|
|
|
|
$(INSTALL_DIR) $(1)/etc/uci-defaults
|
|
$(INSTALL_BIN) ./root/etc/uci-defaults/99-secubox-firstboot $(1)/etc/uci-defaults/
|
|
|
|
$(INSTALL_DIR) $(1)/etc/secubox/profiles
|
|
$(INSTALL_DIR) $(1)/etc/secubox/templates
|
|
$(INSTALL_DIR) $(1)/etc/secubox/macros
|
|
|
|
# Install profile JSON files
|
|
-$(INSTALL_DATA) ./root/etc/secubox/profiles/*.json $(1)/etc/secubox/profiles/ 2>/dev/null || true
|
|
|
|
# Install template files
|
|
-$(INSTALL_DATA) ./root/etc/secubox/templates/*.json $(1)/etc/secubox/templates/ 2>/dev/null || true
|
|
|
|
$(INSTALL_DIR) $(1)/usr/sbin
|
|
$(INSTALL_BIN) ./root/usr/sbin/secubox $(1)/usr/sbin/
|
|
$(INSTALL_BIN) ./root/usr/sbin/secubox-core $(1)/usr/sbin/
|
|
$(INSTALL_BIN) ./root/usr/sbin/secubox-appstore $(1)/usr/sbin/
|
|
$(INSTALL_BIN) ./root/usr/sbin/secubox-catalog-sync $(1)/usr/sbin/
|
|
$(INSTALL_BIN) ./root/usr/sbin/secubox-profile $(1)/usr/sbin/
|
|
$(INSTALL_BIN) ./root/usr/sbin/secubox-diagnostics $(1)/usr/sbin/
|
|
$(INSTALL_BIN) ./root/usr/sbin/secubox-recovery $(1)/usr/sbin/
|
|
$(INSTALL_BIN) ./root/usr/sbin/secubox-verify $(1)/usr/sbin/
|
|
$(INSTALL_BIN) ./root/usr/sbin/secubox-state $(1)/usr/sbin/
|
|
$(INSTALL_BIN) ./root/usr/sbin/secubox-component $(1)/usr/sbin/
|
|
$(INSTALL_BIN) ./root/usr/sbin/secubox-sync-registry $(1)/usr/sbin/
|
|
|
|
$(INSTALL_DIR) $(1)/usr/libexec/rpcd
|
|
$(INSTALL_BIN) ./root/usr/libexec/rpcd/luci.secubox $(1)/usr/libexec/rpcd/
|
|
|
|
$(INSTALL_DIR) $(1)/usr/share/secubox/modules
|
|
$(INSTALL_DIR) $(1)/usr/share/secubox/plugins/catalog
|
|
$(INSTALL_DIR) $(1)/usr/share/secubox/scripts
|
|
$(INSTALL_DATA) ./root/usr/share/secubox/scripts/* $(1)/usr/share/secubox/scripts/
|
|
$(INSTALL_BIN) ./root/usr/share/secubox/state-machine.sh $(1)/usr/share/secubox/
|
|
|
|
# Install main catalog files (REQUIRED for AppStore)
|
|
-$(INSTALL_DATA) ./root/usr/share/secubox/catalog.json $(1)/usr/share/secubox/ 2>/dev/null || true
|
|
-$(INSTALL_DATA) ./root/usr/share/secubox/catalog-stats.json $(1)/usr/share/secubox/ 2>/dev/null || true
|
|
-$(INSTALL_DATA) ./root/usr/share/secubox/catalog-metadata.json.example $(1)/usr/share/secubox/ 2>/dev/null || true
|
|
|
|
# Install individual module catalog files
|
|
-$(INSTALL_DATA) ./root/usr/share/secubox/plugins/catalog/*.json $(1)/usr/share/secubox/plugins/catalog/ 2>/dev/null || true
|
|
endef
|
|
|
|
define Package/secubox-core/postinst
|
|
#!/bin/sh
|
|
[ -n "$${IPKG_INSTROOT}" ] || {
|
|
# Create catalog cache directories
|
|
mkdir -p /var/cache/secubox/catalogs
|
|
mkdir -p /var/lib/secubox
|
|
mkdir -p /var/log
|
|
chmod 755 /var/cache/secubox/catalogs
|
|
chmod 700 /var/lib/secubox
|
|
|
|
# Initialize state database and component registry
|
|
if [ ! -f /var/lib/secubox/state-db.json ]; then
|
|
cat > /var/lib/secubox/state-db.json <<'EOF'
|
|
{
|
|
"components": {},
|
|
"version": "1.0",
|
|
"last_updated": ""
|
|
}
|
|
EOF
|
|
fi
|
|
|
|
if [ ! -f /var/lib/secubox/component-registry.json ]; then
|
|
cat > /var/lib/secubox/component-registry.json <<'EOF'
|
|
{
|
|
"components": {},
|
|
"version": "1.0",
|
|
"last_updated": ""
|
|
}
|
|
EOF
|
|
fi
|
|
|
|
/etc/init.d/secubox-core enable
|
|
/etc/init.d/secubox-core start
|
|
|
|
# Register with rpcd
|
|
/etc/init.d/rpcd restart
|
|
|
|
# Sync component registry from catalog
|
|
if [ -x /usr/sbin/secubox-sync-registry ]; then
|
|
echo "Syncing component registry..."
|
|
/usr/sbin/secubox-sync-registry sync
|
|
fi
|
|
|
|
echo "SecuBox Core Framework v0.9.0 installed successfully"
|
|
echo "Run 'secubox device status' to verify installation"
|
|
echo "New features: State management, Component registry, Admin Control Center"
|
|
}
|
|
exit 0
|
|
endef
|
|
|
|
define Package/secubox-core/prerm
|
|
#!/bin/sh
|
|
[ -n "$${IPKG_INSTROOT}" ] || {
|
|
/etc/init.d/secubox-core stop
|
|
/etc/init.d/secubox-core disable
|
|
}
|
|
exit 0
|
|
endef
|
|
|
|
$(eval $(call BuildPackage,secubox-core))
|