26 lines
448 B
Bash
Executable File
26 lines
448 B
Bash
Executable File
#!/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 |