NetworkManager
When using NetworkManager, it is posible to start a VPN connection after a successful wireless connection.
I have autofs configured on my home directory, so I need to start autofs after VPN connection:
/etc/NetworkManager/dispatcher.d/10autofs
#!/bin/bash
SERVER='172.16.1.1'
# Nothing to do if user does not have requisite binaries.
ping -c 1 $SERVER &>/dev/null
if [ $? -ne 0 ]; then
# server is down so unmount
/etc/init.d/autofs stop
else
# server is up
/etc/init.d/autofs start
fi