The new /usr/local/bin/keeponline.sh looks like this:
#!/bin/bash
echo "Going Online..."
/usr/local/bin/online.sh > /dev/null
while true; do
ping -c 1 -W 120 www.google.com > /dev/null
if [ "$?" = "0" ]; then
echo "You are connected"
else
/usr/local/bin/online.sh > /dev/null
echo "Disconnect detected at `date`, reconnecting" >> /home/akudewan/logs/keeponline.log
fi
sleep 10m
done
Next I make another script, keeponline-launch inside /etc/network/if-up.d/
#!/bin/bash
# Not for loopback!
[ "$IFACE" != "lo" ] || exit 0
sh /usr/local/bin/keeponline.sh &
exit 0
This will basically launch the keeponline script when the network interface comes up :)
(Thanks to Vivaldi Gloria from ubuntuforums)
No comments:
Post a Comment