Implement three-tier permission management across all SecuBox modules: **1. Package-Level Permissions (PKG_FILE_MODES)** - Add PKG_FILE_MODES to all 15 module Makefiles - RPCD scripts: 755 (executable) - CSS/JS/JSON files: 644 (default, no config needed) - Ensures correct permissions at installation time **2. Runtime Permission Fix** - New script: /usr/libexec/secubox/fix-permissions.sh - RPCD method: luci.secubox fix_permissions - UI control: "🔧 Fix Perms" button in Quick Actions - Fixes all permissions and restarts services **3. Automation & Documentation** - secubox-tools/add-pkg-file-modes.sh: Auto-configure PKG_FILE_MODES - PERMISSIONS-GUIDE.md: Comprehensive permissions guide - MODULE-ENABLE-DISABLE-DESIGN.md: Enable/disable system design doc - Updated Makefile template with PKG_FILE_MODES pattern **Modules Updated:** - luci-app-auth-guardian - luci-app-bandwidth-manager - luci-app-cdn-cache - luci-app-client-guardian - luci-app-crowdsec-dashboard - luci-app-ksm-manager - luci-app-media-flow - luci-app-netdata-dashboard - luci-app-netifyd-dashboard - luci-app-network-modes - luci-app-secubox (+ fix-permissions.sh script) - luci-app-system-hub - luci-app-traffic-shaper - luci-app-vhost-manager - luci-app-wireguard-dashboard **Benefits:** - No more manual permission fixes after installation - Users can fix permissions from UI without SSH access - Proper OpenWrt package management compliance - Automated detection and configuration 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
187 lines
3.9 KiB
JavaScript
187 lines
3.9 KiB
JavaScript
'use strict';
|
|
'require baseclass';
|
|
'require rpc';
|
|
|
|
/**
|
|
* SecuBox Master API
|
|
* Package: luci-app-secubox
|
|
* RPCD object: luci.secubox
|
|
*/
|
|
|
|
// Version: 0.3.1
|
|
|
|
var callStatus = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'status',
|
|
expect: { }
|
|
});
|
|
|
|
var callModules = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'modules',
|
|
expect: {}
|
|
});
|
|
|
|
var callModulesByCategory = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'modules_by_category',
|
|
params: ['category'],
|
|
expect: {}
|
|
});
|
|
|
|
var callModuleInfo = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'module_info',
|
|
params: ['module'],
|
|
expect: { }
|
|
});
|
|
|
|
var callStartModule = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'start_module',
|
|
params: ['module']
|
|
});
|
|
|
|
var callStopModule = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'stop_module',
|
|
params: ['module']
|
|
});
|
|
|
|
var callRestartModule = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'restart_module',
|
|
params: ['module']
|
|
});
|
|
|
|
// NEW v0.3.1: Enable/Disable module methods
|
|
var callEnableModule = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'enable_module',
|
|
params: ['module'],
|
|
expect: { success: false, message: '' }
|
|
});
|
|
|
|
var callDisableModule = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'disable_module',
|
|
params: ['module'],
|
|
expect: { success: false, message: '' }
|
|
});
|
|
|
|
var callCheckModuleEnabled = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'check_module_enabled',
|
|
params: ['module'],
|
|
expect: { enabled: false }
|
|
});
|
|
|
|
var callHealth = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'health',
|
|
expect: { checks: [], overall: '' }
|
|
});
|
|
|
|
var callDiagnostics = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'diagnostics',
|
|
expect: { }
|
|
});
|
|
|
|
var callSystemHealth = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'get_system_health',
|
|
expect: { }
|
|
});
|
|
|
|
var callAlerts = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'get_alerts',
|
|
expect: { alerts: [] }
|
|
});
|
|
|
|
var callQuickAction = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'quick_action',
|
|
params: ['action'],
|
|
expect: { }
|
|
});
|
|
|
|
var callDashboardData = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'get_dashboard_data',
|
|
expect: { }
|
|
});
|
|
|
|
var callGetTheme = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'get_theme',
|
|
expect: { }
|
|
});
|
|
|
|
var callDismissAlert = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'dismiss_alert',
|
|
params: ['alert_id'],
|
|
expect: { }
|
|
});
|
|
|
|
var callClearAlerts = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'clear_alerts',
|
|
expect: { }
|
|
});
|
|
|
|
var callFixPermissions = rpc.declare({
|
|
object: 'luci.secubox',
|
|
method: 'fix_permissions',
|
|
expect: { success: false, message: '', output: '' }
|
|
});
|
|
|
|
function formatUptime(seconds) {
|
|
if (!seconds) return '0s';
|
|
var d = Math.floor(seconds / 86400);
|
|
var h = Math.floor((seconds % 86400) / 3600);
|
|
var m = Math.floor((seconds % 3600) / 60);
|
|
if (d > 0) return d + 'd ' + h + 'h';
|
|
if (h > 0) return h + 'h ' + m + 'm';
|
|
return m + 'm';
|
|
}
|
|
|
|
function formatBytes(bytes) {
|
|
if (!bytes) return '0 B';
|
|
var k = 1024;
|
|
var sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
var i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
return (bytes / Math.pow(k, i)).toFixed(2) + ' ' + sizes[i];
|
|
}
|
|
|
|
return baseclass.extend({
|
|
getStatus: callStatus,
|
|
getModules: callModules,
|
|
getModulesByCategory: callModulesByCategory,
|
|
getModuleInfo: callModuleInfo,
|
|
// DEPRECATED: Use enable/disable instead
|
|
startModule: callStartModule,
|
|
stopModule: callStopModule,
|
|
restartModule: callRestartModule,
|
|
// NEW v0.3.1: Enable/Disable methods
|
|
enableModule: callEnableModule,
|
|
disableModule: callDisableModule,
|
|
checkModuleEnabled: callCheckModuleEnabled,
|
|
// Health & diagnostics
|
|
getHealth: callHealth,
|
|
getDiagnostics: callDiagnostics,
|
|
getSystemHealth: callSystemHealth,
|
|
getAlerts: callAlerts,
|
|
quickAction: callQuickAction,
|
|
getDashboardData: callDashboardData,
|
|
getTheme: callGetTheme,
|
|
dismissAlert: callDismissAlert,
|
|
clearAlerts: callClearAlerts,
|
|
fixPermissions: callFixPermissions,
|
|
// Utilities
|
|
formatUptime: formatUptime,
|
|
formatBytes: formatBytes
|
|
});
|