Skip to content

Commit

Permalink
ensure speedtest source
Browse files Browse the repository at this point in the history
  • Loading branch information
ipitio committed Feb 19, 2024
1 parent 028c8ac commit 6453fde
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 40 deletions.
67 changes: 31 additions & 36 deletions advanced/Scripts/speedtestmod/mod.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ install() {
fi

local PHP_VERSION=$(php -v | head -n 1 | awk '{print $2}' | cut -d "." -f 1,2)
local PKG_MANAGER=$(command -v apt-get || command -v yum || command -v dnf)
local PKG_MANAGER=$(command -v apt-get || command -v dnf || command -v yum)
local PKGS=(bc sqlite3 jq tmux wget "php$PHP_VERSION-sqlite3")

if [[ "$PKG_MANAGER" == *"apt-get"* ]]; then
Expand All @@ -151,48 +151,43 @@ install() {
done

if [ ${#missingPkgs[@]} -gt 0 ]; then
sudo $PKG_MANAGER install -y "${missingPkgs[@]}"
$PKG_MANAGER install -y "${missingPkgs[@]}"
fi

if [[ "$PKG_MANAGER" == *"yum"* || "$PKG_MANAGER" == *"dnf"* ]]; then
if [ ! -f /etc/yum.repos.d/ookla_speedtest-cli.repo ]; then
echo "Adding speedtest source for RPM..."
curl -sSLN https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.rpm.sh | sudo bash
fi
elif [[ "$PKG_MANAGER" == *"apt-get"* ]]; then
if [ ! -f /etc/apt/sources.list.d/ookla_speedtest-cli.list ]; then
echo "Adding speedtest source for DEB..."
if [ -e /etc/os-release ]; then
. /etc/os-release
local base="ubuntu debian"
local os=${ID}
local dist=${VERSION_CODENAME}
if [ ! -z "${ID_LIKE-}" ] && [[ "${base//\"/}" =~ "${ID_LIKE//\"/}" ]] && [ "${os}" != "ubuntu" ]; then
os=${ID_LIKE%% *}
[ -z "${UBUNTU_CODENAME-}" ] && UBUNTU_CODENAME=$(/usr/bin/lsb_release -cs)
dist=${UBUNTU_CODENAME}
[ -z "$dist" ] && dist=${VERSION_CODENAME}
if notInstalled speedtest && notInstalled speedtest-cli; then
if [[ "$PKG_MANAGER" == *"yum"* || "$PKG_MANAGER" == *"dnf"* ]]; then
if [ ! -f /etc/yum.repos.d/ookla_speedtest-cli.repo ]; then
echo "Adding speedtest source for RPM..."
curl -sSLN https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.rpm.sh | sudo bash
fi
elif [[ "$PKG_MANAGER" == *"apt-get"* ]]; then
if [ ! -f /etc/apt/sources.list.d/ookla_speedtest-cli.list ]; then
echo "Adding speedtest source for DEB..."
if [ -e /etc/os-release ]; then
. /etc/os-release
local base="ubuntu debian"
local os=${ID}
local dist=${VERSION_CODENAME}
if [ ! -z "${ID_LIKE-}" ] && [[ "${base//\"/}" =~ "${ID_LIKE//\"/}" ]] && [ "${os}" != "ubuntu" ]; then
os=${ID_LIKE%% *}
[ -z "${UBUNTU_CODENAME-}" ] && UBUNTU_CODENAME=$(/usr/bin/lsb_release -cs)
dist=${UBUNTU_CODENAME}
[ -z "$dist" ] && dist=${VERSION_CODENAME}
fi
wget -O /tmp/script.deb.sh https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh >/dev/null 2>&1
chmod +x /tmp/script.deb.sh
os=$os dist=$dist /tmp/script.deb.sh
rm -f /tmp/script.deb.sh
else
curl -sSLN https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash
fi
wget -O /tmp/script.deb.sh https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh >/dev/null 2>&1
chmod +x /tmp/script.deb.sh
os=$os dist=$dist /tmp/script.deb.sh
rm -f /tmp/script.deb.sh
else
curl -sSLN https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash
fi
fi
$PKG_MANAGER install -y speedtest
fi

if notInstalled speedtest && notInstalled speedtest-cli; then
sudo $PKG_MANAGER install -y speedtest
fi
if [ -f /usr/local/bin/speedtest ]; then
rm -f /usr/local/bin/speedtest
ln -s /usr/bin/speedtest /usr/local/bin/speedtest
fi

download /opt mod_pihole https://github.com/arevindh/pi-hole
download $admin_dir admin https://github.com/arevindh/AdminLTE web
download /opt mod_pihole https://github.com/ipitio/pi-hole "" ipitio
download $admin_dir admin https://github.com/ipitio/AdminLTE web
if [ -f $curr_wp ]; then
if ! cat $curr_wp | grep -q SpeedTest; then
cp -af $curr_wp $org_wp
Expand Down
40 changes: 36 additions & 4 deletions advanced/Scripts/speedtestmod/speedtest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ notInstalled() {
mv -f "$out" /var/log/pihole/speedtest.log
exit 1
fi

return 1
}

Expand Down Expand Up @@ -112,11 +113,41 @@ run() {
echo "Test Failed!" >/tmp/speedtest_results
savetest "$start" "$stop"
else
if notInstalled speedtest-cli; then
swaptest speedtest-cli speedtest
else
if notInstalled speedtest; then
local PKG_MANAGER=$(command -v apt-get || command -v dnf || command -v yum)
if [[ "$PKG_MANAGER" == *"yum"* || "$PKG_MANAGER" == *"dnf"* ]]; then
if [ ! -f /etc/yum.repos.d/ookla_speedtest-cli.repo ]; then
echo "Adding speedtest source for RPM..."
curl -sSLN https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.rpm.sh | sudo bash
fi
elif [[ "$PKG_MANAGER" == *"apt-get"* ]]; then
if [ ! -f /etc/apt/sources.list.d/ookla_speedtest-cli.list ]; then
echo "Adding speedtest source for DEB..."
if [ -e /etc/os-release ]; then
. /etc/os-release
local base="ubuntu debian"
local os=${ID}
local dist=${VERSION_CODENAME}
if [ ! -z "${ID_LIKE-}" ] && [[ "${base//\"/}" =~ "${ID_LIKE//\"/}" ]] && [ "${os}" != "ubuntu" ]; then
os=${ID_LIKE%% *}
[ -z "${UBUNTU_CODENAME-}" ] && UBUNTU_CODENAME=$(/usr/bin/lsb_release -cs)
dist=${UBUNTU_CODENAME}
[ -z "$dist" ] && dist=${VERSION_CODENAME}
fi
wget -O /tmp/script.deb.sh https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh >/dev/null 2>&1
chmod +x /tmp/script.deb.sh
os=$os dist=$dist /tmp/script.deb.sh
rm -f /tmp/script.deb.sh
else
curl -sSLN https://packagecloud.io/install/repositories/ookla/speedtest-cli/script.deb.sh | sudo bash
fi
fi
fi
swaptest speedtest speedtest-cli
else
swaptest speedtest-cli speedtest
fi

run $1 $((${2:-1} + 1))
fi
}
Expand All @@ -126,7 +157,8 @@ main() {
sudo "$0" "$@"
exit $?
fi
echo "Running test..."

echo "Running Test..."
run $1 # Number of attempts
}

Expand Down

0 comments on commit 6453fde

Please sign in to comment.