Clean out scripts

This commit is contained in:
Russel Yasol
2025-08-27 21:36:43 +08:00
parent e054ada872
commit 5d7df898f3
3 changed files with 0 additions and 145 deletions

View File

@@ -1,35 +0,0 @@
#!/bin/sh
# Location: /www/cgi-bin/quecmanager/home/speedtest/check_speedtest.sh
echo "Content-Type: application/json"
echo ""
# Check if speedtest binary exists and is executable
if ! command -v speedtest >/dev/null 2>&1; then
echo '{"status":"error","message":"Speedtest binary not found in PATH","available":false}'
exit 1
fi
# Get speedtest binary location
SPEEDTEST_PATH=$(which speedtest 2>/dev/null)
# Check if binary is executable
if [ ! -x "$SPEEDTEST_PATH" ]; then
echo '{"status":"error","message":"Speedtest binary is not executable","available":false,"path":"'$SPEEDTEST_PATH'"}'
exit 1
fi
# Try to get version (this also checks if binary works)
VERSION_OUTPUT=$(speedtest --version 2>/dev/null | head -1)
if [ $? -ne 0 ]; then
echo '{"status":"error","message":"Speedtest binary exists but is not working properly","available":false,"path":"'$SPEEDTEST_PATH'"}'
exit 1
fi
# Check if license is already accepted
LICENSE_CHECK=$(timeout 5 speedtest --accept-license --help 2>/dev/null | grep -i "usage\|help" | head -1)
if [ -z "$LICENSE_CHECK" ]; then
echo '{"status":"warning","message":"Speedtest binary may need license acceptance","available":true,"path":"'$SPEEDTEST_PATH'","version":"'$VERSION_OUTPUT'"}'
else
echo '{"status":"ok","message":"Speedtest is properly installed and ready","available":true,"path":"'$SPEEDTEST_PATH'","version":"'$VERSION_OUTPUT'"}'
fi

View File

@@ -1,55 +0,0 @@
#!/bin/sh
# Location: /www/cgi-bin/quecmanager/home/speedtest/cleanup_speedtest.sh
echo "Content-Type: application/json"
echo ""
# Configuration
STATUS_FILE="/tmp/speedtest_status.json"
FINAL_RESULT="/tmp/speedtest_final.json"
PID_FILE="/tmp/speedtest.pid"
LOG_FILE="/tmp/speedtest.log"
CLEANED_FILES=""
KILLED_PROCESSES=""
# Kill any running speedtest processes
if [ -f "$PID_FILE" ]; then
PID=$(cat "$PID_FILE" 2>/dev/null)
if [ -n "$PID" ] && kill -0 "$PID" 2>/dev/null; then
kill -9 "$PID" 2>/dev/null
KILLED_PROCESSES="$PID"
fi
fi
# Also kill any speedtest processes that might be running without PID file
STRAY_PIDS=$(ps | grep speedtest | grep -v grep | awk '{print $1}' 2>/dev/null)
if [ -n "$STRAY_PIDS" ]; then
for pid in $STRAY_PIDS; do
kill -9 "$pid" 2>/dev/null
if [ -n "$KILLED_PROCESSES" ]; then
KILLED_PROCESSES="$KILLED_PROCESSES,$pid"
else
KILLED_PROCESSES="$pid"
fi
done
fi
# Remove all speedtest-related files
for file in "$STATUS_FILE" "$FINAL_RESULT" "$PID_FILE" "$LOG_FILE"; do
if [ -f "$file" ]; then
rm -f "$file"
if [ -n "$CLEANED_FILES" ]; then
CLEANED_FILES="$CLEANED_FILES,$(basename $file)"
else
CLEANED_FILES="$(basename $file)"
fi
fi
done
# Prepare response
if [ -n "$CLEANED_FILES" ] || [ -n "$KILLED_PROCESSES" ]; then
echo '{"status":"cleaned","message":"Cleanup completed","cleaned_files":"'$CLEANED_FILES'","killed_processes":"'$KILLED_PROCESSES'","timestamp":'$(date +%s)'}'
else
echo '{"status":"clean","message":"No cleanup needed","timestamp":'$(date +%s)'}'
fi

View File

@@ -1,55 +0,0 @@
#!/bin/sh
# Location: /www/cgi-bin/quecmanager/home/speedtest/stop_speedtest.sh
# Configuration
STATUS_FILE="/tmp/speedtest_status.json"
FINAL_RESULT="/tmp/speedtest_final.json"
PID_FILE="/tmp/speedtest.pid"
LOG_FILE="/tmp/speedtest.log"
# Set headers
echo "Content-Type: application/json"
echo ""
# Function to cleanup all speedtest files
cleanup_all() {
rm -f "$STATUS_FILE" "$FINAL_RESULT" "$PID_FILE" "$LOG_FILE"
}
# Check if speedtest is running
if [ -f "$PID_FILE" ]; then
PID=$(cat "$PID_FILE" 2>/dev/null)
if [ -n "$PID" ] && kill -0 "$PID" 2>/dev/null; then
# Kill the process
kill "$PID" 2>/dev/null
sleep 1
# Force kill if still running
if kill -0 "$PID" 2>/dev/null; then
kill -9 "$PID" 2>/dev/null
fi
# Wait for process to die
count=0
while kill -0 "$PID" 2>/dev/null && [ $count -lt 5 ]; do
sleep 1
count=$((count + 1))
done
# Log the cancellation
echo "Speedtest cancelled at $(date)" >> "$LOG_FILE" 2>/dev/null
# Cleanup files
cleanup_all
echo '{"status":"cancelled","message":"Speedtest cancelled successfully","timestamp":'$(date +%s)'}'
else
# PID file exists but process is not running
cleanup_all
echo '{"status":"not_running","message":"No active speedtest found","timestamp":'$(date +%s)'}'
fi
else
# No PID file, cleanup any stale files
cleanup_all
echo '{"status":"not_running","message":"No active speedtest found","timestamp":'$(date +%s)'}'
fi