Skip to content

Instantly share code, notes, and snippets.

@saidinesh5
Created November 4, 2017 21:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saidinesh5/898850edac7aee14d45b9da14d9865f9 to your computer and use it in GitHub Desktop.
Save saidinesh5/898850edac7aee14d45b9da14d9865f9 to your computer and use it in GitHub Desktop.
The script I use to automatically login to my Act Fibernet
#!/bin/sh
LOGIN_USERNAME="<your mail id>%40<your mail provider>.com"
LOGIN_PASSWORD="<your password>"
LOGIN_SERVER_ADDRESS="http://portal.actcorp.in"
LOGIN_PAGE="/tmp/loginPage"
CONNECTIVITY_CHECK_PING_TIMEOUT=3
CONNECTIVITY_CHECK_PING_HOST=www.google.com
#NOTIFICATION LEDs for our shiny login script
#On openwrt, we need kmod-ledtrig-timer for the fancy blinking: https://wiki.openwrt.org/doc/uci/system#timer
LED_GREEN_1=/sys/class/leds/gl-ar150\:wan/
LED_GREEN_2=/sys/class/leds/gl-ar150\:lan/
LED_RED=/sys/class/leds/gl-ar150\:wlan/
notification_disconnected() {
echo $@
echo none > $LED_GREEN_1/trigger
echo 0 > $LED_GREEN_1/brightness
echo none > $LED_GREEN_2/trigger
echo 0 > $LED_GREEN_2/brightness
echo timer > $LED_RED/trigger
echo 200 > $LED_RED/delay_on
}
notification_connecting() {
echo $@
echo none > $LED_GREEN_1/trigger
echo 0 > $LED_GREEN_1/brightness
echo timer > $LED_GREEN_2/trigger
echo 200 > $LED_GREEN_2/delay_on
echo none > $LED_RED/trigger
echo 0 > $LED_RED/brightness
}
notification_connected() {
echo $@
echo none > $LED_GREEN_1/trigger
echo 1 > $LED_GREEN_1/brightness
echo none > $LED_GREEN_2/trigger
echo 0 > $LED_GREEN_2/brightness
echo none > $LED_RED/trigger
echo 0 > $LED_RED/brightness
}
die() {
notification_disconnected $@
exit 1
}
check_connectivity() {
ping -q -c 1 -W $CONNECTIVITY_CHECK_PING_TIMEOUT $CONNECTIVITY_CHECK_PING_HOST &> /dev/null
}
notification_connecting "Checking your internet connectivity..."
check_connectivity && notification_connected "You are already logged in to the internet" && exit 0
notification_connecting "Internet connectivity not found. Fetching login page..."
wget --quiet -O $LOGIN_PAGE $LOGIN_SERVER_ADDRESS || die "Error: Unable to fetch login page"
LOGIN_URL=`cat $LOGIN_PAGE | grep "form action=" | grep "act\/login" | grep -oE \"[^\"]*\" | grep http | grep -oE "[^\"]*"`
LOGIN_USERIP=`cat $LOGIN_PAGE | grep "userIP" | grep -o \"[^\"]*\" | grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}"`
[[ -z $LOGIN_URL ]] && die "Error: Unable to fetch login details"
notification_connecting "Logging $LOGIN_USERIP into $LOGIN_URL"
curl --silent -X POST --data "userIP=$LOGIN_USERIP&_login_WAR_BeamPromotionalNDownloadsportlet_uname=$LOGIN_USERNAME&pword=$LOGIN_PASSWORD" $LOGIN_URL > /tmp/loginResponse.html || die "Error: Unable to submit login request"
sleep 5
check_connectivity && notification_connected "You have successfully logged in" || die "Error logging you in!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment