#/bin/sh
status_old=0
status=1
while true
do
result=$(ethtool eth0 | grep "Link detected: yes")
if [[ "$result" != "" ]];
then
echo "eth0 link"
status=1
else
echo "eth0 not link"
status=0
fi
if [ $status_old != $status ];
then
status_old=$status
if [ $status -eq 1 ];
then
ifconfig wlan0 down
else
ifconfig wlan0 up
fi
fi
sleep 10
done