just check the uplink
This commit is contained in:
26
bash/ethlnkchk
Executable file
26
bash/ethlnkchk
Executable 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
|
Reference in New Issue
Block a user