Last active
April 28, 2020 20:40
-
-
Save fasmide/0986ff998d7e84645ae2637d048f0d0b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SITES="dr.dk 1.1.1.1 8.8.8.8 google.com aau.dk tv2.dk" | |
ERRORSUM=0 | |
for i in $SITES | |
do | |
ping -q -i 10 -c 10 ${i} & | |
done | |
for i in $SITES | |
do | |
if ! wait -n; | |
then | |
ERRORSUM=$(($ERRORSUM + 1)); | |
fi | |
done | |
AS_ARRAY=($SITES) | |
LENGTH=${#AS_ARRAY[@]} | |
echo "$ERRORSUM/$LENGTH sites failed" | |
if [ $ERRORSUM -eq $LENGTH ] | |
then | |
echo "all sites failed, resetting usbbus" | |
uhubctl -a cycle -d 10 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment