reworked log and logError for pipes

This commit is contained in:
2023-04-01 12:07:04 +02:00
parent 7f40e79b57
commit 1b131f5799
5 changed files with 119 additions and 28 deletions

View File

@@ -0,0 +1,25 @@
#!/bin/bash
# Usage: doSpeedtest [<interface>] [<speedtest-server-id>]
function doSpeedtest {
if ! [ "${1}" = "" ]; then
INTERFACE=${1}
INTERFACE_ARG="-I ${INTERFACE}"
INTERFACE_TEXT=" from NIC '${INTERFACE}'"
fi
if ! [ "${2}" = "" ]; then
SERVER_ID=${2}
SERVER_ARG="-s ${SERVER_ID}"
SERVER_ID_TEXT=" to server ${SERVER_ID}"
fi
logScript "Doing internet speedtest${INTERFACE_TEXT}${SERVER_ID_TEXT}"
if ! OUT=$(speedtest -f json); then
logError "Speedtest failed"
logError "${OUT}"
else
echo
fi
}