This repository has been archived on 2024-09-01. You can view files and clone it, but cannot push or open issues or pull requests.
al-skel/home/bin/check-network

29 lines
794 B
Bash
Executable File

#!/usr/bin/env bash
count=0
disconnected="/"
disconnected2="\\"
wireless_connected=""
ethernet_connected=""
while true; do
if ! (ping -c 1 archlabslinux.com || ping -c 1 google.com || ping -c 1 bitbucket.org) &>/dev/null; then
if ! (ping -c 1 github.com || ping -c 1 sourceforge.net) &>/dev/null; then
echo "$disconnected" ; sleep 0.6
echo "$disconnected2" ; sleep 0.6
fi
else
# avoid checking what type of interface it is every loop
if (( count < 1 )); then
ID="$(ip link | awk '/state UP/ {print $2}')"
((count++))
fi
if [[ $ID == e* ]]; then
echo "$ethernet_connected" ; sleep 20
else
echo "$wireless_connected" ; sleep 20
fi
fi
done