I got sick of connecting the Cisco VPN client every time I got to university. To automate this whole process I made use of adding a network event and some script fiddling (original version is here).
1) Add this to /System/Library/SystemConfiguration/Kicker.bundle/Contents/Resources/Kicker.xml. It triggers the corresponding script upon a network event such as plugging in a network cable or connecting to a wireless network.
2) A small Python script extracts the IP address and wireless SSID and checks wether it should trigger the (below) vpn script. Perhaps you need to change the Python path, since it is my rather special OS X setup.
import os, sys
#gets SSID
ssid = os.popen(’/System/Library/PrivateFrameworks/Apple80211.framework¬
/Versions/A/Resources/airport -I | fgrep -i ” ssid” | grep -Eo “[a-zA-Z0-9]+$”‘)
#get’s first part of IP in format 130.82
ip = os.popen(’ifconfig en0 | grep “inet ” | grep -v 127.0.0.1 | cut -d\ -f2 | cut -c -6′)
if ip.read() == ‘130.82\n’ or ssid.read() == ‘public\n’ :
connect = os.system(’/Users/fluppel/vpnconnect.sh &’)
if connect == 0:
print “initiating VPN..”
else:
print “aborting”
sys.exit()
3) This bash script takes care of (re-)loading the Cisco VPN kernel extension and connecting to a default profile (courtesy of Samuel).
No Comments
Leave a Reply