Copy QuecManager beta to non-beta

QM BETA --> regular/non-beta
This commit is contained in:
Cameron Thompson
2025-08-31 02:17:49 -04:00
parent 6d6a3775c4
commit 02dafc73ad
391 changed files with 4494 additions and 740 deletions

View File

@@ -0,0 +1,103 @@
#!/bin/sh /etc/rc.common
START=48
STOP=11
USE_PROCD=1
# QuecManager Logging Management Service
# Handles log rotation, cleanup, and logging system initialization
start_service() {
echo "Starting QuecManager Logging Management..."
# Initialize centralized logging system
echo "Initializing centralized logging directories..."
# Source logger with error handling
if . /www/cgi-bin/services/quecmanager_logger.sh 2>/dev/null; then
qm_init_logs
LOGGER_AVAILABLE=1
else
echo "Warning: Could not load logger, creating directories manually"
mkdir -p "/tmp/quecmanager/logs/daemons" "/tmp/quecmanager/logs/services" "/tmp/quecmanager/logs/settings" "/tmp/quecmanager/logs/system" 2>/dev/null || true
LOGGER_AVAILABLE=0
fi
# Set proper permissions
chmod 755 "/tmp/quecmanager/logs" "/tmp/quecmanager/logs/daemons" "/tmp/quecmanager/logs/services" "/tmp/quecmanager/logs/settings" "/tmp/quecmanager/logs/system" 2>/dev/null || true
# Create status and readme files
cat > "/tmp/quecmanager/logs/status.json" <<EOF
{
"status": "initialized",
"timestamp": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
"directories": {
"daemons": "/tmp/quecmanager/logs/daemons",
"services": "/tmp/quecmanager/logs/services",
"settings": "/tmp/quecmanager/logs/settings",
"system": "/tmp/quecmanager/logs/system"
}
}
EOF
chmod 644 "/tmp/quecmanager/logs/status.json" 2>/dev/null || true
# Create README for administrators
cat > "/tmp/quecmanager/logs/README.txt" <<EOF
QuecManager Centralized Logging
==============================
This directory contains organized log files for the QuecManager system.
Directory Structure:
- daemons/ - Background daemon logs (memory_daemon, ping_daemon, etc.)
- services/ - Service logs (quecwatch, quecprofile, etc.)
- settings/ - Configuration and settings script logs
- system/ - System-level logs and initialization
Log Format:
[YYYY-MM-DD HH:MM:SS] [LEVEL] [SCRIPT] [PID:xxxx] Message
Log Rotation:
- Files are automatically rotated when they exceed 500KB
- Up to 2 backup files are kept (.1, .2)
- Old backup files are cleaned up periodically
Web Access:
Use /cgi-bin/quecmanager/experimental/logs/fetch_logs.sh to view logs.
Maintenance:
Automatic cleanup runs every 6 hours via this service.
EOF
chmod 644 "/tmp/quecmanager/logs/README.txt" 2>/dev/null || true
# Log the initialization (only if logger is available)
if [ "$LOGGER_AVAILABLE" = "1" ]; then
qm_log_info "system" "quecmanager_logging" "Centralized logging system initialized"
fi
echo "Centralized logging directories initialized"
# Start periodic log cleanup daemon
echo "Starting periodic log cleanup daemon..."
procd_open_instance cleanup
procd_set_param command sh -c 'while true; do sleep 21600; /www/cgi-bin/services/cleanup_logs.sh; done'
procd_set_param respawn
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
echo "Log cleanup daemon started (runs every 6 hours)"
# Log the completion (only if logger is available)
if [ "$LOGGER_AVAILABLE" = "1" ]; then
qm_log_info "system" "quecmanager_logging" "QuecManager logging management started - cleanup every 6 hours"
fi
echo "QuecManager Logging Management started"
}
stop_service() {
# Log shutdown (only if logger is available)
if . /www/cgi-bin/services/quecmanager_logger.sh 2>/dev/null; then
qm_log_info "system" "quecmanager_logging" "QuecManager logging management stopping" 2>/dev/null || true
fi
# procd will handle stopping all instances automatically
echo "Stopping QuecManager Logging Management."
}

View File

@@ -33,6 +33,67 @@ start_service() {
procd_close_instance
echo "Signal Metrics Logger started"
# Start the QCAINFO Interpreter
echo "Starting QCAINFO Interpreter..."
procd_open_instance
procd_set_param command /www/cgi-bin/services/network_insights_interpreter.sh
procd_set_param respawn
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
echo "QCAINFO Interpreter started"
# Start ping daemon if enabled in configuration
PING_CONFIG_FILE="/etc/quecmanager/settings/ping_settings.conf"
if [ -f "$PING_CONFIG_FILE" ]; then
PING_ENABLED=$(awk -F'=' '/^PING_ENABLED=/ {print $2}' "$PING_CONFIG_FILE" 2>/dev/null | tr -d '"' | tr -d ' ')
echo "Ping config found. PING_ENABLED='$PING_ENABLED'"
case "$PING_ENABLED" in
true|1|on|yes|enabled)
echo "Starting Ping Daemon..."
procd_open_instance
procd_set_param command /www/cgi-bin/services/ping_daemon.sh
procd_set_param respawn
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
echo "Ping Daemon started"
;;
*)
echo "Ping Daemon disabled in configuration (value: '$PING_ENABLED')"
;;
esac
else
echo "Ping configuration not found at $PING_CONFIG_FILE, skipping Ping Daemon"
fi
# Start memory daemon if enabled in configuration
CONFIG_FILE="/etc/quecmanager/settings/memory_settings.conf"
if [ -f "$CONFIG_FILE" ]; then
# More robust parsing for OpenWrt/BusyBox
MEMORY_ENABLED=$(awk -F'=' '/^MEMORY_ENABLED=/ {print $2}' "$CONFIG_FILE" 2>/dev/null | tr -d '"' | tr -d ' ')
echo "Memory config found. MEMORY_ENABLED='$MEMORY_ENABLED'"
case "$MEMORY_ENABLED" in
true|1|on|yes|enabled)
echo "Starting Memory Daemon..."
procd_open_instance
procd_set_param command /www/cgi-bin/services/memory_daemon.sh
procd_set_param respawn
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
echo "Memory Daemon started"
;;
*)
echo "Memory Daemon disabled in configuration (value: '$MEMORY_ENABLED')"
;;
esac
else
echo "Memory configuration not found at $CONFIG_FILE, skipping Memory Daemon"
fi
echo "All QuecManager services Started"
}