-
Notifications
You must be signed in to change notification settings - Fork 3
/
install-speedtest
179 lines (167 loc) · 7.34 KB
/
install-speedtest
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#Requires -RunAsAdministrator
#!/bin/bash
# How to use:
#
# Linux:
# wget -qO- CLITools.tk/install-speedtest>st.sh; chmod +x st.sh; ./st.sh
# wget -qO- speedtestcli.tk>st.sh; chmod +x st.sh; ./st.sh
# Windows:
# from cmd: powershell -C "start-process -verb runAs "powershell" -argumentlist ""/COMMAND set-executionpolicy remotesigned; wget speedtestcli.tk -O speedtestcli.ps1; ./speedtestcli.ps1; set-executionpolicy default; echo exit"""
# from admin powershell: set-executionpolicy remotesigned; wget speedtestcli.tk -O speedtestcli.ps1; ./speedtestcli.ps1; set-executionpolicy default
#
# Only Github:
# Linux:
# wget -qO- https://raw.githubusercontent.com/marrobHD/clitools/master/install-speedtest>st.sh; chmod +x st.sh; ./st.sh
# Windows:
# from cmd: powershell -C "start-process -verb runAs "powershell" -argumentlist ""/COMMAND set-executionpolicy remotesigned; wget https://raw.githubusercontent.com/marrobHD/clitools/master/install-speedtest -O speedtestcli.ps1; ./speedtestcli.ps1; set-executionpolicy default; echo exit"""
# from admin powershell: set-executionpolicy remotesigned; wget https://raw.githubusercontent.com/marrobHD/clitools/master/install-speedtest -O speedtestcli.ps1; ./speedtestcli.ps1; set-executionpolicy default
echo ""
echo ""
echo "Name: Speedtest.net CLI Installer"
echo "Version: 0.0.7 - Stable"
echo "Date: 06.07.2021"
echo "Author: TechHome/marrobhd"
echo "Source: info.clitools.tk"
echo ""
echo ""
echo "Installation has been started"
echo "----------------------------------------------------------"
# Bash code
# --------------------
#bash cd ~
#bash res1=$(date +%s.%N)
#bash
#bash # Script only works if sudo caches the password for a few minutes
#bash sudo true
#bash
#bash if DISTRIBUTER=$(lsb_release -si); then
#bash echo
#bash echo
#bash else
#bash echo Trying to fix errors...
#bash sudo yum install redhat-lsb-core -y
#bash zypper install -y lsb-release
#bash apt-get install lsb-release -y
#bash DISTRIBUTER=$(lsb_release -si)
#bash OS=$(lsb_release -sd)
#bash echo "Operating-System: $OS"
#bash fi
#bash
#bash export DEB_DISTRO=$(lsb_release -sc)
#bash echo $DEB_DISTRO
#bash echo $DISTRIBUTER
#bash
#bash if grep -c "^" /etc/apt/sources.list.d/speedtest.list | grep -q '1'; then
#bash echo "Removing old speedtest list"
#bash rm -f /etc/apt/sources.list.d/speedtest.list
#bash else
#bash echo "No previous installation detected. Migration not needed!"
#bash fi
#bash
#bash if [ "$DISTRIBUTER" == "Ubuntu" ] || [ "$DISTRIBUTER" == "Zorin" ] || [ "$DISTRIBUTER" == "Raspbian" ] || [ "$DISTRIBUTER" == "Debian" ]; then
#bash echo $DISTRIBUTER
#bash export DEB_DISTRO=bionic
#bash sudo apt-get install gnupg1 apt-transport-https dirmngr bc -y
#bash wget -qO- https://raw.githubusercontent.com/marrobHD/clitools/master/speedtest-lnx-deb-fetch | sudo bash
#bash # Other non-official binaries will conflict with Speedtest CLI
#bash # Example how to remove using apt-get
#bash sudo apt-get remove speedtest-cli
#bash sudo apt-get install speedtest -y
#bash elif [ "$DISTRIBUTER" == "openSUSE" ]; then
#bash echo $DISTRIBUTER
#bash zypper install -y speedtest-cli bc
#bash elif [ "$DISTRIBUTER" == "Fedora" ] || [ "$DISTRIBUTER" == "CentOS" ]; then
#bash echo $DISTRIBUTER
#bash #sudo yum install wget bc -y
#bash #wget https://bintray.com/ookla/rhel/rpm -O bintray-ookla-rhel.repo
#bash #sudo mv bintray-ookla-rhel.repo /etc/yum.repos.d/
#bash # Other non-official binaries will conflict with Speedtest CLI
#bash # Example how to remove using yum
#bash # rpm -qa | grep speedtest | xargs -I {} sudo yum -y remove {}
#bash wget -qO- https://install.speedtest.net/app/cli/install.rpm.sh | sudo bash
#bash sudo yum install speedtest -y
#bash exit
#bash elif true; then
#bash echo $DISTRIBUTER
#bash 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
#bash # Example how to remove conflicting or old versions using pkg
#bash # sudo pkg remove speedtest
#bash sudo pkg add "https://install.speedtest.net/app/cli/ookla-speedtest-1.0.0-freebsd.pkg"
#bash exit
#bash fi
#bash
#bash
#bash echo
#bash echo ----------------------------------------------------------
#bash echo Installed! Just run 'speedtest'
#bash res2=$(date +%s.%N)
#bash dt=$(echo "$res2 - $res1" | bc)
#bash dd=$(echo "$dt/86400" | bc)
#bash dt2=$(echo "$dt-86400*$dd" | bc)
#bash dh=$(echo "$dt2/3600" | bc)
#bash dt3=$(echo "$dt2-3600*$dh" | bc)
#bash dm=$(echo "$dt3/60" | bc)
#bash ds=$(echo "$dt3-60*$dm" | bc)
#bash LC_NUMERIC=C printf "Total runtime: %d:%02d:%02d:%02.4f\n" $dd $dh $dm $ds
#bash echo
# PowerShell code
# --------------------
#posh Add-Type -AssemblyName System.IO.Compression.FileSystem
#posh cd ~
#posh $OS = (Get-WmiObject -class Win32_OperatingSystem).Caption | Out-String
#posh echo "Operating-System: $OS"
#posh
#posh # $stopwatch = [System.Diagnostics.Stopwatch]::StartNew() || echo "Please make sure, that you're running this in PowerShell!" && exit 1 -ErrorAction SilentlyContinue -EV Err -EA
#posh $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
#posh
#posh if($OS -match "Microsoft Windows"){
#posh } else {
#posh echo "Your Operating-System isn't 'Microsoft Windows'"
#posh echo "exiting..."
#posh exit
#posh }
#posh
#posh function changePath ($action, $addendum) {
#posh $regLocation =
#posh "Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment"
#posh $path = (Get-ItemProperty -Path $regLocation -Name PATH).path
#posh
#posh # Add an item to PATH
#posh if ($action -eq "add") {
#posh $path = "$path;$addendum"
#posh Set-ItemProperty -Path $regLocation -Name PATH -Value $path
#posh }
#posh
#posh # Remove an item from PATH
#posh if ($action -eq "remove") {
#posh $path = ($path.Split(';') | Where-Object { $_ -ne "$addendum" }) -join ';'
#posh Set-ItemProperty -Path $regLocation -Name PATH -Value $path
#posh }
#posh }
#posh
#posh wget https://install.speedtest.net/app/cli/ookla-speedtest-1.0.0-win64.zip -O ookla-speedtest-win64.zip
#posh mkdir $env:COMMONPROGRAMFILES\Speedtest.net\
#posh [System.IO.Compression.ZipFile]::ExtractToDirectory("$env:homepath\ookla-speedtest-win64.zip", "$env:COMMONPROGRAMFILES\Speedtest.net\")
#posh changePath "remove" "$env:COMMONPROGRAMFILES\Speedtest.net\"
#posh changePath "add" "$env:COMMONPROGRAMFILES\Speedtest.net\"
#posh [Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Program Files\Common Files\Speedtest.net\", "USER")
#posh # remove envvar with changePath "remove" "$env:COMMONPROGRAMFILES\Speedtest.net\"
#posh
#posh
#posh $stopwatch.Stop()
#posh $elapsedSecods = $stopwatch.Elapsed.Seconds
#posh echo ""
#posh echo "----------------------------------------------------------"
#posh echo "Installed! Just run 'speedtest'"
#posh echo "Total runtime: $elapsedSecods seconds"
#posh echo ""
#posh rm \WINDOWS\System32\speedtestcli.ps1
#posh echo "You can close this now"
#posh sleep 6
function RunBashStuff {
echo "This script may won't work if you run without saving it. eg: wget -qO- speedtestcli.tk>st.sh; chmod +x st.sh; ./st.sh"
eval "$(grep '^#bash' $0 | sed -e 's/^#bash //')"
}
"RunBashStuff"
"exit"
((Get-Content $MyInvocation.MyCommand.Source) -match '^#posh ' -replace '^#posh ') -join "`n" | Invoke-Expression