McGill Wireless - if-up script

Posted

Last blog entry I displayed an Epiphany plugin to solve one of my McGill wireless woes. Today I spent about 45 minutes playing with wget and bash, and I came up with a much better solution. It's quite McGill-specific, and unfortunately for many of my friends it won't work on Windows, but here it is:

Dump the following into /etc/network/if-up.d/00mcgill-wireless-login:

 /dev/null
[ $? -eq 0 ] || exit 0

# Bizarre variables for the authentication page
LOGIN_PAGE=https://wireless-login.mcgill.ca/wireless/webpages/noc-authenticate.php
NAS_HOST=www.noc-cn3000.com
NAS_IP=`host $NAS_HOST | sed -n -e '/^.*has address (.*)/{s//1/;p;q;}'`

# Pretend we're a web browser
wget "$LOGIN_PAGE" -o /dev/null -O /dev/null 
        "--post-data=username=$USERNAME&password=$PASSWORD&button=Login&ipaddress=$ADDR&CN3000_INT_IP=$NAS_IP"]]>