Version: 1.0.0 Last Updated: 2025-12-28 Status: Active
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
IMPORTANT: Before working on any code, consult these guides:
⚠️ RÈGLES CRITIQUES À TOUJOURS RESPECTER:
luci.system-hub)system-hub/overview.js)./secubox-tools/fix-permissions.sh --local (avant commit)./secubox-tools/fix-permissions.sh --remote (après deploy)./secubox-tools/validate-modules.sh avant commit
var(--sh-*), jamais hardcoder les couleurs[data-theme="dark"]--sh-primary → --sh-primary-end pour dégradésSecuBox is a comprehensive security and network management suite for OpenWrt. The repository contains 13 LuCI application packages that provide dashboards for security monitoring, network intelligence, access control, bandwidth management, and system administration.
# Build a single package
make package/luci-app-<module-name>/compile V=s
# Clean build for a package
make package/luci-app-<module-name>/clean
make package/luci-app-<module-name>/compile V=s
# Install package to staging directory
make package/luci-app-<module-name>/install
# Transfer to router
scp bin/packages/*/base/luci-app-*.ipk root@192.168.1.1:/tmp/
# Install on router
ssh root@192.168.1.1
opkg install /tmp/luci-app-*.ipk
/etc/init.d/rpcd restart
/etc/init.d/uhttpd restart
# Fix file permissions FIRST (CRITICAL)
./secubox-tools/fix-permissions.sh --local
# Run comprehensive module validation (RECOMMENDED - 7 checks)
./secubox-tools/validate-modules.sh
# Checks:
# 1. RPCD script names vs ubus objects
# 2. Menu paths vs view file locations
# 3. View files have menu entries
# 4. RPCD script permissions (755)
# 5. JSON syntax validation
# 6. ubus object naming convention
# 7. htdocs file permissions (644 for CSS/JS) ← NEW
# Validate shell scripts (RPCD backends)
shellcheck luci-app-*/root/usr/libexec/rpcd/*
# Validate JSON files
find . -name "*.json" -exec jsonlint {} \;
# Run automated repair tool
./secubox-tools/secubox-repair.sh
# Fix permissions on deployed router
./secubox-tools/fix-permissions.sh --remote
# Run diagnostics
./secubox-tools/secubox-debug.sh luci-app-<module-name>
The local-build.sh script allows you to build and test packages locally, replicating the GitHub Actions workflows:
# Validate all packages (syntax, JSON, shell scripts)
./secubox-tools/local-build.sh validate
# Build all packages for x86_64
./secubox-tools/local-build.sh build
# Build single package
./secubox-tools/local-build.sh build luci-app-system-hub
# Build for specific architecture
./secubox-tools/local-build.sh build --arch aarch64-cortex-a72
# Full validation + build
./secubox-tools/local-build.sh full
# Clean build artifacts
./secubox-tools/local-build.sh clean
Supported architectures:
x86-64 - PC, VMs (default)aarch64-cortex-a53 - ARM Cortex-A53 (ESPRESSObin)aarch64-cortex-a72 - ARM Cortex-A72 (MOCHAbin, RPi4)aarch64-generic - Generic ARM64mips-24kc - MIPS 24Kc (TP-Link)mipsel-24kc - MIPS LE (Xiaomi, GL.iNet)The script automatically:
build/<arch>/Package Format Support:
.apk format (new Alpine-based package manager).ipk format (opkg package manager)Environment variables:
OPENWRT_VERSION - OpenWrt version (default: 24.10.5, also supports: 25.12.0-rc1, 23.05.5, SNAPSHOT)SDK_DIR - SDK directory (default: ./sdk)BUILD_DIR - Build output directory (default: ./build)CACHE_DIR - Download cache directory (default: ./cache)All SecuBox modules follow a standard LuCI application structure:
luci-app-<module-name>/
├── Makefile # OpenWrt package definition
├── README.md # Module documentation
├── htdocs/luci-static/resources/
│ ├── view/<module-name>/ # JavaScript UI views
│ │ ├── overview.js # Main dashboard view
│ │ └── *.js # Additional views
│ └── <module-name>/
│ ├── api.js # RPC API client module
│ └── dashboard.css # Module-specific styles
└── root/
├── etc/config/<module-name> # UCI configuration (optional)
└── usr/
├── libexec/rpcd/
│ └── luci.<module-name> # RPCD backend script (MUST use luci. prefix!)
└── share/
├── luci/menu.d/ # Menu JSON definition
│ └── luci-app-<module-name>.json
└── rpcd/acl.d/ # ACL permissions JSON
└── luci-app-<module-name>.json
htdocs/luci-static/resources/
form and view classesapi.js module using L.resolveDefault()ui.js (Dropdown, Checkbox, Combobox, etc.)root/usr/libexec/rpcd/
ubus call <module> <method>root/usr/share/luci/menu.d/luci-app-<module>.json
root/usr/share/rpcd/acl.d/luci-app-<module>.json
IMPORTANT: The following naming rules are MANDATORY for modules to work correctly:
The RPCD script filename MUST exactly match the ubus object name used in JavaScript:
// In JavaScript (htdocs/luci-static/resources/view/*/):
var callStatus = rpc.declare({
object: 'luci.cdn-cache', // ← This object name
method: 'status'
});
# RPCD script filename MUST match:
root/usr/libexec/rpcd/luci.cdn-cache # ← Must be exactly 'luci.cdn-cache'
Common Error: If the names don’t match, you’ll get:
RPC call to luci.cdn-cache/status failed with error -32000: Object not foundCommand failed: Method not foundSolution: All RPCD scripts MUST use the luci. prefix:
luci.cdn-cache, luci.system-hub, luci.wireguard-dashboardcdn-cache, system-hub, wireguard-dashboardMenu JSON path entries MUST correspond to actual view files:
// In menu.d/luci-app-netifyd-dashboard.json:
{
"action": {
"type": "view",
"path": "netifyd-dashboard/overview" // ← Must match file location
}
}
# View file MUST exist at:
htdocs/luci-static/resources/view/netifyd-dashboard/overview.js
# ↑ Same path as menu ↑
Common Error: If paths don’t match:
HTTP error 404 while loading class file '/luci-static/resources/view/netifyd/overview.js'Solution: Ensure menu paths match directory structure:
netifyd-dashboard/overview → file view/netifyd-dashboard/overview.jsnetifyd/overview → file view/netifyd-dashboard/overview.jsAll ubus objects MUST start with luci. prefix:
// ✅ Correct:
object: 'luci.cdn-cache'
object: 'luci.system-hub'
object: 'luci.wireguard-dashboard'
// ❌ Wrong:
object: 'cdn-cache'
object: 'systemhub'
ALWAYS run validation before deploying:
./secubox-tools/validate-modules.sh
This script checks:
Each package Makefile must define:
PKG_NAME: Package name (must match directory)PKG_VERSION: Version numberPKG_RELEASE: Package release numberLUCI_TITLE: Display title in LuCILUCI_DEPENDS: Package dependencies (e.g., +luci-base +rpcd)LUCI_DESCRIPTION: Brief descriptionPKG_MAINTAINER: Maintainer name and emailPKG_LICENSE: License (typically Apache-2.0)The Makefile includes luci.mk from the LuCI build system which handles installation.
cp -r templates/luci-app-template luci-app-newmodulehtdocs/ and root/RPCD backends are shell scripts that:
$1 for the method nameprintf or echocase statements for method routing. /lib/functions.shExample:
#!/bin/sh
case "$1" in
list)
echo '{ "status": {}, "stats": {} }'
;;
call)
case "$2" in
status)
# Output JSON
printf '{"running": true, "version": "1.0.0"}\n'
;;
esac
;;
esac
Views extend L.view and implement load() and render():
'use strict';
'require view';
'require form';
'require <module>/api as API';
return L.view.extend({
load: function() {
return Promise.all([
API.getStatus(),
API.getStats()
]);
},
render: function(data) {
var m, s, o;
m = new form.Map('config', _('Title'));
s = m.section(form.TypedSection, 'section');
// Add form fields...
return m.render();
}
});
ARM64: aarch64-cortex-a53, aarch64-cortex-a72, aarch64-generic, mediatek-filogic, rockchip-armv8, bcm27xx-bcm2711
ARM32: arm-cortex-a7-neon, arm-cortex-a9-neon, qualcomm-ipq40xx, qualcomm-ipq806x
MIPS: mips-24kc, mipsel-24kc, mipsel-74kc
x86: x86-64, x86-generic
makefiles/: Reference Makefiles for modules (backup/templates)secubox-tools/: Repair and debugging utilities
secubox-repair.sh: Auto-fixes Makefile and RPCD issuessecubox-debug.sh: Validates package structuretemplates/: Package templates for creating new modules.github/workflows/: CI/CD automation scriptsError: RPC call to luci.cdn-cache/status failed with error -32000: Object not found
Cause: RPCD script name doesn’t match ubus object name in JavaScript
Solution:
grep -r "object:" luci-app-*/htdocs --include="*.js"
luci. prefix):
mv root/usr/libexec/rpcd/cdn-cache root/usr/libexec/rpcd/luci.cdn-cache
/etc/init.d/rpcd restart
Error: HTTP error 404 while loading class file '/luci-static/resources/view/netifyd/overview.js'
Cause: Menu path doesn’t match actual view file location
Solution:
grep '"path":' root/usr/share/luci/menu.d/*.json
ls htdocs/luci-static/resources/view/
After installing/updating a package:
/etc/init.d/rpcd restart
/etc/init.d/uhttpd restart
Check that:
jsonlint root/usr/share/luci/menu.d/*.jsonroot/usr/share/rpcd/acl.d/*.jsonLUCI_DEPENDSCommon causes:
include ../../luci.mk)luci. prefix)Use repair tool: ./secubox-tools/secubox-repair.sh
Run the validation script to check all naming conventions:
./secubox-tools/validate-modules.sh
./secubox-tools/validate-modules.sh
# Or use the local build tool:
./secubox-tools/local-build.sh validate
jsonlint <file>.jsonshellcheck <script># Build single package
./secubox-tools/local-build.sh build luci-app-<name>
# Or build with manual SDK:
make package/luci-app-<name>/compile V=s
./secubox-tools/secubox-repair.shgit tag -a v1.0.0 -m "Release 1.0.0"luci. prefix)./secubox-tools/validate-modules.sh before committing'use strict';all (no compiled code)