Created
June 3, 2014 11:49
-
-
Save sharang-webonise/abf222ae7db98ea5c4d6 to your computer and use it in GitHub Desktop.
This script connects you to the internet through Cyberoam
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Replace NAME with your username and PASS with your password that you use to connect to Cyberoam. | |
Now add this script to your your crontab like so: | |
$ crontab -e | |
Add the following entry: | |
* * * * * /home/webonise/.shell_scripts/cron_jobs/webonise_cyberoam_login.sh | |
Replace the path with wherever the above mentioned script lies on your system. | |
The script will be executed every minute. It will check if you are connected to the Internet and if not it will connect you. | |
Basically it uses the ping command to ping the google DNS server and scrapes the output to calculate the packet loss. | |
Then it logs you in using the credentials you specified if you are not already connected. | |
PS. You need to have `curl` installed on your system for this to work. | |
I was too lazy to check for the existence of it in the above script! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
packet_loss=`ping -c 1 8.8.8.8 | tail -2 | head -1 | cut -d ' ' -f 6 | sed s/.$//` | |
if [ $packet_loss -eq 100 ] | |
then | |
query_string="mode=191&username=NAME&password=PASS&a=$(date +'%s')&producttype=0" | |
curl -d "${query_string}" -H "Content-Type:application/x-www-form-urlencoded" http://10.0.0.1:8090/login.xml | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice one! Actually I also had created a function which logs in over our cyberoam.
I have to just run
switch_on
while startup. Didn't got caught in connection drop issue alike you, BTW.