Skip to content

Instantly share code, notes, and snippets.

@fasmide
Last active Apr 28, 2020
Embed
What would you like to do?
#!/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