Portal (luci-app-secubox-portal): - Fix service status showing 0/9 by checking if init scripts exist - Only count installed services in status display - Use pgrep fallback when init script status fails nDPId Dashboard (luci-app-ndpid): - Add default /etc/config/ndpid configuration - Add /etc/init.d/ndpid-compat init script - Enable compat service in postinst for app detection - Fix Makefile to install init script and config CrowdSec Dashboard: - Add CLAUDE.md with OpenWrt-specific guidelines (pgrep without -x) - CSS fixes for hiding LuCI left menu in all views - LAPI repair improvements with retry logic New Packages: - secubox-app-crowdsec: OpenWrt-native CrowdSec package - secubox-app-netifyd: Netifyd DPI integration - luci-app-secubox: Core SecuBox hub - luci-theme-secubox: Custom theme Removed: - luci-app-secubox-crowdsec (replaced by crowdsec-dashboard) - secubox-crowdsec-setup (functionality moved to dashboard) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
88 lines
1.6 KiB
Bash
Executable File
88 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
#
|
|
# SecuBox Log Aggregator / Logger
|
|
# Central log file: /var/log/seccubox.log
|
|
|
|
LOG_FILE="/var/log/seccubox.log"
|
|
TAG="secubox"
|
|
MESSAGE=""
|
|
PAYLOAD=""
|
|
TAIL_COUNT=""
|
|
MODE="append"
|
|
|
|
ensure_log() {
|
|
local dir
|
|
dir="$(dirname "$LOG_FILE")"
|
|
[ -d "$dir" ] || mkdir -p "$dir"
|
|
touch "$LOG_FILE"
|
|
}
|
|
|
|
write_entry() {
|
|
ensure_log
|
|
printf '%s [%s] %s\n' "$(date -Iseconds)" "$TAG" "$MESSAGE" >> "$LOG_FILE"
|
|
[ -n "$PAYLOAD" ] && printf '%s\n' "$PAYLOAD" >> "$LOG_FILE"
|
|
}
|
|
|
|
write_snapshot() {
|
|
ensure_log
|
|
{
|
|
printf '===== SNAPSHOT %s =====\n' "$(date -Iseconds)"
|
|
printf '--- DMESG (tail -n 200) ---\n'
|
|
dmesg | tail -n 200
|
|
printf '--- LOGREAD (tail -n 200) ---\n'
|
|
logread 2>/dev/null | tail -n 200
|
|
printf '===== END SNAPSHOT =====\n'
|
|
} >> "$LOG_FILE"
|
|
}
|
|
|
|
tail_log() {
|
|
ensure_log
|
|
if [ -n "$TAIL_COUNT" ]; then
|
|
tail -n "$TAIL_COUNT" "$LOG_FILE"
|
|
else
|
|
tail "$LOG_FILE"
|
|
fi
|
|
}
|
|
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
--tag)
|
|
TAG="$2"; shift 2;;
|
|
--message|-m)
|
|
MESSAGE="$2"; shift 2;;
|
|
--payload|-p)
|
|
PAYLOAD="$2"; shift 2;;
|
|
--snapshot)
|
|
MODE="snapshot"; shift;;
|
|
--tail)
|
|
MODE="tail"; TAIL_COUNT="$2"; shift 2;;
|
|
--tail-all)
|
|
MODE="tail"; TAIL_COUNT=""; shift;;
|
|
-h|--help)
|
|
cat <<'EOF'
|
|
secubox-log --tag TAG --message MSG [--payload TEXT]
|
|
secubox-log --snapshot # append dmesg+logread snapshot
|
|
secubox-log --tail [N] # print last N lines (default 10)
|
|
EOF
|
|
exit 0;;
|
|
*)
|
|
shift;;
|
|
esac
|
|
done
|
|
|
|
case "$MODE" in
|
|
snapshot)
|
|
write_snapshot
|
|
;;
|
|
tail)
|
|
tail_log
|
|
;;
|
|
*)
|
|
if [ -z "$MESSAGE" ]; then
|
|
echo "Usage: secubox-log --message 'text' [--tag tag]" >&2
|
|
exit 1
|
|
fi
|
|
write_entry
|
|
;;
|
|
esac
|