Created
August 19, 2019 15:00
-
-
Save sharang-d/9d72ce1026afe542afc80f91e9aae55e 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/sharang/.shell_scripts/cron_jobs/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. | |
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 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