Hot patch for speedtest

This commit is contained in:
Russel Yasol
2025-03-14 11:46:14 +08:00
parent 11f9ee2bbf
commit aac8079bc6
64 changed files with 366 additions and 87 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,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,10 @@
#!/bin/sh
# /www/cgi-bin/start_speedtest.sh
echo "Content-Type: application/json"
echo ""
# Run speedtest in background
/www/cgi-bin/quecmanager/home/speedtest/speedtest.sh
# Immediately return a success response
echo '{"status":"started"}'