-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall-speedtest-lnx
96 lines (84 loc) · 3.06 KB
/
install-speedtest-lnx
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/bin/bash
# How to use:
# Linux:
# wget -qO- CLITools.tk/install-speedtest-lnx | bash
echo ""
echo ""
echo "Name: Speedtest.net CLI Installer Linux"
echo "Version: 0.0.7 - Stable"
echo "Date: 17.08.2021"
echo "Author: TechHome/marrobhd"
echo "Source: info.clitools.tk"
echo ""
echo ""
echo "Installation has been started"
echo "----------------------------------------------------------"
# Bash code
# --------------------
cd ~
res1=$(date +%s.%N)
# Script only works if sudo caches the password for a few minutes
sudo true
if DISTRIBUTER=$(lsb_release -si); then
echo
echo
else
echo Trying to fix errors...
sudo yum install redhat-lsb-core -y
zypper install -y lsb-release
apt-get install lsb-release -y
DISTRIBUTER=$(lsb_release -si)
OS=$(lsb_release -sd)
echo "Operating-System: $OS"
fi
export DEB_DISTRO=$(lsb_release -sc)
echo $DEB_DISTRO
echo $DISTRIBUTER
if grep -c "^" /etc/apt/sources.list.d/speedtest.list | grep -q '1'; then
echo "Removing old speedtest list"
rm -f /etc/apt/sources.list.d/speedtest.list
else
echo No previous installation detected!
fi
if [ "$DISTRIBUTER" == "Ubuntu" ] || [ "$DISTRIBUTER" == "Zorin" ] || [ "$DISTRIBUTER" == "Raspbian" ] || [ "$DISTRIBUTER" == "Debian" ]; then
echo $DISTRIBUTER
export DEB_DISTRO=bionic
sudo apt-get install gnupg1 apt-transport-https dirmngr bc -y
wget -qO- https://raw.githubusercontent.com/marrobHD/clitools/master/speedtest-lnx-deb-fetch | sudo bash
# Other non-official binaries will conflict with Speedtest CLI
# Example how to remove using apt-get
sudo apt-get remove speedtest-cli
sudo apt-get install speedtest -y
elif [ "$DISTRIBUTER" == "openSUSE" ]; then
echo $DISTRIBUTER
zypper install -y speedtest-cli bc
elif [ "$DISTRIBUTER" == "Fedora" ] || [ "$DISTRIBUTER" == "CentOS" ]; then
echo $DISTRIBUTER
#sudo yum install wget bc -y
#wget https://bintray.com/ookla/rhel/rpm -O bintray-ookla-rhel.repo
#sudo mv bintray-ookla-rhel.repo /etc/yum.repos.d/
# Other non-official binaries will conflict with Speedtest CLI
# Example how to remove using yum
# rpm -qa | grep speedtest | xargs -I {} sudo yum -y remove {}
wget -qO- https://install.speedtest.net/app/cli/install.rpm.sh | sudo bash
sudo yum install speedtest -y
elif true; then
echo $DISTRIBUTER
sudo pkg update || echo "'$DISTRIBUTER' isn't listed in this script. Considering opening an issue on GitHub!"; exit && sudo pkg install -g libidn2 ca_root_nss
# Example how to remove conflicting or old versions using pkg
# sudo pkg remove speedtest
sudo pkg add "https://install.speedtest.net/app/cli/ookla-speedtest-1.0.0-freebsd.pkg"
fi
echo
echo ----------------------------------------------------------
echo Installed! Just run 'speedtest'
res2=$(date +%s.%N)
dt=$(echo "$res2 - $res1" | bc)
dd=$(echo "$dt/86400" | bc)
dt2=$(echo "$dt-86400*$dd" | bc)
dh=$(echo "$dt2/3600" | bc)
dt3=$(echo "$dt2-3600*$dh" | bc)
dm=$(echo "$dt3/60" | bc)
ds=$(echo "$dt3-60*$dm" | bc)
LC_NUMERIC=C printf "Total runtime: %d:%02d:%02d:%02.4f\n" $dd $dh $dm $ds
echo