just check the uplink

This commit is contained in:
2018-06-18 16:17:57 +02:00
parent 2b9928329b
commit 11f11f59fa
2 changed files with 127 additions and 0 deletions

26
bash/ethlnkchk Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
if [ "$( /usr/bin/id --user )" -ne 0 ] ; then
printf "U have to be root\\!"
exit 1
fi
if [ ! -x "/sbin/ethtool" ] ; then
printf "U have to install ethtool first\\!"
exit 2
fi
ETH="eth0"
CNT=0
while true ; do
if ! /sbin/ethtool "${ETH}" 2>/dev/null | /bin/grep "Link detected: yes" 1>/dev/null ; then
(( CNT++ ))
else
CNT=0
fi
if [ "${CNT}" -gt 6 ] ; then /home/pi/bin/sesame close ; fi
sleep 6
done
exit 0