Skip to content

Instantly share code, notes, and snippets.

@mturch
Forked from mbierman/install_speedtest.sh
Created August 11, 2022 02:21
Show Gist options
  • Save mturch/475dfc3d668d3fcbc0d543a5dce5e089 to your computer and use it in GitHub Desktop.
Save mturch/475dfc3d668d3fcbc0d543a5dce5e089 to your computer and use it in GitHub Desktop.
Install Speedtest for firewalla
#!/bin/bash
# 2.0
# https://gist.github.com/mbierman/9ac6a35622ee5a0c631ed6f6ad74b722
# Put this script in ~/.firewalla/config/post_main.d in order to resinstall after upgrades
log=/data/fw_reboot.txt
if ! [ -w $log ] ; then
sudo touch $log
sudo chmod a+w $log
fi
app=speedtest
edate=$(date +'%a %b %d %H:%M:%S %Z %Y')
Cversion=$(curl https://www.speedtest.net/apps/cli | egrep -o '<a href="https://install.speedtest.net/app/cli/ookla-speedtest-([0-9]{1,}\.)+([0-9]{1,}\.)+([0-9]{1,})+-linux-x86_64.tgz">x86_64</a>' | cut -f3 -d "-")
install () {
# unalias apt
# unalias apt-get
# sudo apt update
# sudo apt-get install curl
# curl -s https://install.speedtest.net/app/cli/install.deb.sh | sudo bash
# sudo apt-get install speedtest
# sudo apt-get update -yq
# curl -s https://install.speedtest.net/app/cli/install.deb.sh | sudo bash
# sudo apt-get install -yq $app
file=$(/etc/apt/sources.list.d/speedtest.list)
[ -f "$file" ] && sudo sudo rm $file
echo -e "\n\nremoving old speedtest\n\n"
export DEBIAN_FRONTEND=noninteractive
binary=ookla-speedtest-${Cversion}-linux-x86_64
curl https://install.speedtest.net/app/cli/${binary}.tgz --output /data/${binary}.tgz
gunzip /data/${binary}.tgz
tar -xvf /data/${binary}.tar
cd /data
rm ${binary}.tar speedtest.5 ${binary}.tar.z
echo -e "$edate $app instaleld!" | tee -a $log
}
if [ -x "/data/speedtest" ]; then
Iversion=$(/data/speedtest --version | grep Linux | sed -e 's|Speedtest by Ookla ||g' | cut -f1 -d" " | cut -f1-3 -d".")
if [ "$Iversion" = "$Cversion" ] ; then
echo -e "\n\n$app instaleld!\n bye"
exit
else
echo "updating speedtest"
install
exit
fi
else
echo "$app could not be found"
echo "installing..."
install
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment