Skip to content

Instantly share code, notes, and snippets.

@fasmide
Last active April 28, 2020 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fasmide/0986ff998d7e84645ae2637d048f0d0b to your computer and use it in GitHub Desktop.
Save fasmide/0986ff998d7e84645ae2637d048f0d0b to your computer and use it in GitHub Desktop.
#!/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