#!/bin/sh
exec >> /tmp/junk 2>&1

# this script goes into /etc/network to make it execute on ifup
# you need to add the line "post-up /etc/network/wlan0-post-up.sh"
# to /etc/network/interfaces for the appropriate interface.
# Please be sure to install /etc/network/wlan0-post-down.sh else
# bad things might happen.

TUNNEL="sunysb"
IFACE="wlan0"
ACTION="CONNECTED"

ESSID=`/sbin/iwconfig $IFACE|awk -F: '/ESSID:\"[^\"]*\"/ {print $2}'`
ESSID=${ESSID//\"/}
ESSID=`echo ${ESSID}|awk '{print $1}'`      #a nasty way to trim
#encryption=`/sbin/iwconfig $IFACE|awk -F: '/Encryption key:/ {print $2}'`
#echo "essid \"$ESSID\""

case "$ESSID" in
       AirNet)
               pon "$TUNNEL"
               ;;
       *)
               ;;
esac


