Code: Select all
netcheck() {
NETERR="Oops"; NETDC="CONN"; touch /tmp/network.nslo
# if [ -e /tmp/network.off ]; then
nice -n 2 nslookup www.google.com >> /tmp/network.nslo &
nice -n 2 nslookup www.yahoo.com >> /tmp/network.nslo &
nice -n 2 nslookup www.facebook.com >> /tmp/network.nslo &
# fi
sleep 5
cat /tmp/network.nslo | grep -ve "0.0.0.0" | grep -E "[0-9]+" && NETERR="muchOK"
echo -n "$NETERR ------ "
rm /tmp/network.nslo
[ -e /tmp/network.disconnect ] && NETDC="NNDC"
pidof firefox-bin && NETDC="NNff"
if [ "$NETERR" == "Oops" ] && [ "$NETDC" != "NNDC" ]; then
L_TITLE_S="Network"; L_MESSAGE_S="XXXXXX Network DisConnected XXXXXXX"; L_BG_S="red"; sleep 1
gxmessage -center -geometry 250x50 -timeout 2 -bg "$L_BG_S" -buttons "" -title "$L_TITLE_S" "$L_MESSAGE_S"
pidof rc.network || /etc/rc.d/rc.network stop
sleep 5
pidof rc.network || /etc/rc.d/rc.network start | tee /tmp/network.rc; sleep 1
grep -e Success /tmp/network.rc > /dev/null && NETERR="CONOK"
rm /tmp/network.rc
if [ "$NETERR" == "CONOK" ]; then
L_MESSAGE_S=" ++ Network Connected ++"; L_BG_S="green"; sleep 1;
gxmessage -center -geometry 250x50 -timeout 1 -bg "$L_BG_S" -buttons "" -title "$L_TITLE_S" "$L_MESSAGE_S"
rm /tmp/network.off
fi
fi
if [ "$NETERR" != "Oops" ] && [ "$NETDC" == "NNDC" ]; then
L_TITLE_S="Network"; L_MESSAGE_S="XXXXXX DisConnectIng Network XXXXXXX"; L_BG_S="yellow"; sleep 1
gxmessage -center -geometry 250x50 -timeout 5 -bg "$L_BG_S" -buttons "" -title "$L_TITLE_S" "$L_MESSAGE_S" &
sleep 1; /etc/rc.d/rc.network stop
touch /tmp/network.off
fi
}
Have fun with this and hope it helps someone else.
Edit: I should have mentioned this is on Lucid-Puppy 5.11