Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save eliza-abraham/a28586821e88bd390fc6 to your computer and use it in GitHub Desktop.
Save eliza-abraham/a28586821e88bd390fc6 to your computer and use it in GitHub Desktop.
This script connects you to the internet through Cyberoam
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!
#!/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