Spaces:
Sleeping
Sleeping
File size: 1,279 Bytes
c001f24 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #!/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."
|