41 lines
921 B
Bash
Executable file
41 lines
921 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
LOG="speedtest.log"
|
|
|
|
if ! command -v speedtest >/dev/null 2>&1; then
|
|
echo "speedtest not found, installing..."
|
|
|
|
|
|
if [[ -f /etc/os-release ]]; then
|
|
. /etc/os-release
|
|
else
|
|
echo "Cannot detect Linux distribution"
|
|
exit 1
|
|
fi
|
|
|
|
case "$ID" in
|
|
ubuntu|debian)
|
|
echo "Detected Ubuntu/Debian"
|
|
sudo apt-get update
|
|
sudo apt-get install -y curl
|
|
curl -s https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash
|
|
sudo apt-get install -y speedtest
|
|
;;
|
|
arch|cachyos)
|
|
echo "Detected Arch Linux"
|
|
sudo pacman -Sy --noconfirm speedtest-cli
|
|
;;
|
|
*)
|
|
echo "Unsupported distribution: $ID"
|
|
exit 1
|
|
;;
|
|
esac
|
|
else
|
|
echo "speedtest already installed"
|
|
fi
|
|
|
|
{
|
|
echo "===== $(date '+%Y-%m-%d %H:%M:%S') ====="
|
|
speedtest --secure | grep -E '^(Hosted by|Download|Upload):'
|
|
echo
|
|
} | tee -a "$LOG"
|