#!/bin/bash # # This script creates a large file and starts a simple web server # to allow you to test the download speed from your server. # FILE_NAME="testfile_100mb" FILE_SIZE_MB=100 PORT=8000 # Create a 100MB file echo "Creating a ${FILE_SIZE_MB}MB test file named ${FILE_NAME}..." dd if=/dev/zero of=${FILE_NAME} bs=1M count=${FILE_SIZE_MB} # Get the server's IP address IP_ADDRESS=$(hostname -I | awk '{print $1}') echo "" echo "------------------------------------------------------------------" echo " Speed Test Server is running." echo "------------------------------------------------------------------" echo " Test file: ${FILE_NAME} (${FILE_SIZE_MB}MB)" echo " Server IP: ${IP_ADDRESS}" echo " Port: ${PORT}" echo "" echo "To test your download speed, open a web browser on your device and go to:" echo "" echo " http://${IP_ADDRESS}:${PORT}/${FILE_NAME}" echo "" echo "Or use this command in your terminal:" echo "" echo " wget http://${IP_ADDRESS}:${PORT}/${FILE_NAME}" echo "" echo "Press Ctrl+C to stop the server." echo "------------------------------------------------------------------" # Start the Python web server python3 -m http.server ${PORT} # Clean up the test file after the server is stopped rm ${FILE_NAME} echo "Test file removed."