QuecManager non-beta

Its about time I did this!
This commit is contained in:
Cameron Thompson
2025-04-02 23:09:08 -04:00
parent c4a340bd36
commit c42907e346
482 changed files with 47267 additions and 109914 deletions

View File

@@ -0,0 +1,11 @@
#!/bin/sh
export HOME=/tmp/home
# Create named pipe for speedtest output if it doesn't exist
[ ! -p /tmp/realtime_spd.json ] && mkfifo /tmp/realtime_spd.json
# Run speedtest in background
/usr/bin/speedtest --accept-license -f json -p yes --progress-update-interval=100 > /tmp/realtime_spd.json
# Remove named pipe
rm /tmp/realtime_spd.json

View File

@@ -0,0 +1,29 @@
#!/bin/sh
# Location: /www/cgi-bin/quecmanager/home/speedtest/speedtest_status.sh
STATUS_FILE="/tmp/speedtest_status.json"
FINAL_RESULT="/tmp/speedtest_final.json"
echo "Content-Type: application/json"
echo "Cache-Control: no-cache, no-store, must-revalidate"
echo "Pragma: no-cache"
echo "Expires: 0"
echo ""
# Check if the test is completed and we have a final result
if [ -f "$FINAL_RESULT" ] && [ -r "$FINAL_RESULT" ] && [ -s "$FINAL_RESULT" ]; then
# Return the saved final result
cat $FINAL_RESULT
elif [ -f "$STATUS_FILE" ]; then
# Check if the file is readable and not empty
if [ -r "$STATUS_FILE" ] && [ -s "$STATUS_FILE" ]; then
# Return current status if test is running
cat $STATUS_FILE
else
# File exists but is empty or not readable
echo '{"status": "pending", "message": "Test initializing..."}'
fi
else
# Indicate no active test
echo '{"status": "not_running"}'
fi

View File

@@ -0,0 +1,13 @@
#!/bin/sh
echo "Content-Type: text/event-stream"
echo "Cache-Control: no-cache"
echo "Connection: keep-alive"
echo ""
# Use cat to read from the FIFO
cat /tmp/realtime_spd.json | while read line; do
echo "data: $line"
echo
sleep 0.1
done

View File

@@ -0,0 +1,36 @@
#!/bin/sh
# Location: /www/cgi-bin/quecmanager/home/speedtest/start_speedtest.sh
STATUS_FILE="/tmp/speedtest_status.json"
FINAL_RESULT="/tmp/speedtest_final.json"
# Set content type header
echo "Content-Type: application/json"
echo ""
# Remove any existing status files
rm -f $STATUS_FILE
rm -f $FINAL_RESULT
# Initialize status file
echo '{"status": "starting"}' > $STATUS_FILE
chmod 644 $STATUS_FILE
# Run speedtest in background and pipe output to status file
(
export HOME=/tmp/home
/usr/bin/speedtest --accept-license -f json -p yes --progress-update-interval=100 | \
while IFS= read -r line; do
# Update status file with latest JSON data
echo "$line" > $STATUS_FILE
# If this is a result line, also save it as the final result
if echo "$line" | grep -q '"type":"result"'; then
echo "$line" > $FINAL_RESULT
chmod 644 $FINAL_RESULT
fi
done
) &
# Return immediate success response
echo '{"status":"started"}'