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,55 @@
#!/bin/sh
# Ping Data Fetch Script - Simplified and OpenWrt compatible
# Always set CORS headers first
echo "Content-Type: application/json"
echo "Access-Control-Allow-Origin: *"
echo "Access-Control-Allow-Methods: GET, OPTIONS"
echo "Access-Control-Allow-Headers: Content-Type"
echo ""
# Handle OPTIONS request and exit early
if [ "${REQUEST_METHOD:-GET}" = "OPTIONS" ]; then
echo "{\"status\":\"success\"}"
exit 0
fi
# Only handle GET requests
if [ "${REQUEST_METHOD:-GET}" != "GET" ]; then
echo "{\"status\":\"error\",\"message\":\"Method not allowed\"}"
exit 0
fi
# Paths
PING_JSON="/tmp/quecmanager/ping_latency.json"
CONFIG_FILE="/etc/quecmanager/settings/ping_settings.conf"
# Check if ping data file exists
if [ -f "$PING_JSON" ] && [ -r "$PING_JSON" ]; then
# Read the file content
ping_data=$(cat "$PING_JSON" 2>/dev/null)
# Check if we got content and it looks like JSON
if [ -n "$ping_data" ] && echo "$ping_data" | grep -q '"timestamp"'; then
# File exists and has content, return it wrapped in success
echo "{\"status\":\"success\",\"data\":$ping_data}"
else
echo "{\"status\":\"error\",\"message\":\"Ping data file is empty or corrupted\"}"
fi
else
# No ping file exists - check configuration
if [ -f "$CONFIG_FILE" ] && [ -r "$CONFIG_FILE" ]; then
# Check if ping monitoring is enabled
if grep -q "^PING_ENABLED=true" "$CONFIG_FILE" 2>/dev/null; then
echo "{\"status\":\"error\",\"message\":\"Ping daemon starting up\"}"
else
echo "{\"status\":\"error\",\"message\":\"Ping monitoring disabled\"}"
fi
else
echo "{\"status\":\"error\",\"message\":\"Ping monitoring not configured\"}"
fi
fi
# Always exit cleanly
exit 0

View File

@@ -0,0 +1,62 @@
#!/bin/sh
# Ping Service Configuration Script - Simple OpenWrt compatible version
# Always set CORS headers first
echo "Content-Type: application/json"
echo "Access-Control-Allow-Origin: *"
echo "Access-Control-Allow-Methods: GET, OPTIONS"
echo "Access-Control-Allow-Headers: Content-Type"
echo ""
# Handle OPTIONS request and exit early
if [ "${REQUEST_METHOD:-GET}" = "OPTIONS" ]; then
echo "{\"status\":\"success\"}"
exit 0
fi
# Only handle GET requests
if [ "${REQUEST_METHOD:-GET}" != "GET" ]; then
echo "{\"status\":\"error\",\"message\":\"Method not allowed\"}"
exit 0
fi
# Configuration path
CONFIG_FILE="/etc/quecmanager/settings/ping_settings.conf"
# Get current configuration
ENABLED="false"
INTERVAL="5"
HOST="8.8.8.8"
if [ -f "$CONFIG_FILE" ] && [ -r "$CONFIG_FILE" ]; then
# Parse config using awk (more reliable in BusyBox)
enabled_val=$(awk -F'=' '/^PING_ENABLED=/ {print $2}' "$CONFIG_FILE" 2>/dev/null | tr -d '"')
interval_val=$(awk -F'=' '/^PING_INTERVAL=/ {print $2}' "$CONFIG_FILE" 2>/dev/null)
host_val=$(awk -F'=' '/^PING_HOST=/ {print $2}' "$CONFIG_FILE" 2>/dev/null | tr -d '"')
case "$enabled_val" in
true|1|on|yes|enabled) ENABLED="true" ;;
*) ENABLED="false" ;;
esac
if echo "$interval_val" | grep -qE '^[0-9]+$' && [ "$interval_val" -ge 1 ] && [ "$interval_val" -le 3600 ]; then
INTERVAL="$interval_val"
fi
if [ -n "$host_val" ]; then
HOST="$host_val"
fi
fi
# Check if ping daemon is running
RUNNING="false"
if pgrep -f "ping_daemon.sh" >/dev/null 2>&1; then
RUNNING="true"
fi
# Return configuration and status
echo "{\"status\":\"success\",\"data\":{\"enabled\":$ENABLED,\"interval\":$INTERVAL,\"host\":\"$HOST\",\"running\":$RUNNING}}"
# Always exit cleanly
exit 0