Skip to content

Instantly share code, notes, and snippets.

@ryanhalliday
Created July 22, 2015 02:05
Show Gist options
  • Save ryanhalliday/072b5270ecbc3aeb4fe9 to your computer and use it in GitHub Desktop.
Save ryanhalliday/072b5270ecbc3aeb4fe9 to your computer and use it in GitHub Desktop.
Automatic configuration script for the Victoria University wireless network
#!/bin/bash
#######
#BASIC SETTINGS
#Include Student\ or Staff\ at the start of your username
USERNAME=
PASSWORD=
#######
#DOCUMENTATION
#Place this file in /etc/NetworkManager/dispatcher.d/ with any name
#
#This may be compatible with other Network managment daemons with some modification
#It depends on $2 to know the action is up, not some other network change.
#Alter that for any other daemons.
#
#The password should be a plain string.
#If you would like some obfuscation, generate your
#password string with `echo "password" | base64`
#then have the password field as $(echo "encryptedpassword" | base64 --decode)
#######
#ADVANCED SETTINGS
SSID="victoria"
TRY_URL="http://google.co.nz"
REDIR_URL="https://wireless.victoria.ac.nz/"
SUBMIT_URL="https://wireless.victoria.ac.nz/login.html"
#######
#Script by Ryan Halliday ([email protected])
######
#Check the action is up, and that the SSID is victoria.
if [ "$2" = "up" ] && [ $(iwgetid -r) = $SSID ]; then
#We will try to access some url and
#check the location header for a redirect
LOCATION=$(curl -s -D - $TRY_URL -o /dev/null | grep Location:)
if [ ${LOCATION:10:32} = $REDIR_URL ]; then
#Send the login data
curl -s --data-urlencode "username=${USERNAME}" --data-urlencode "password=${PASSWORD}" --data "buttonClicked=4" $SUBMIT_URL
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment