Created
June 27, 2011 07:12
-
-
Save lehmannro/1048432 to your computer and use it in GitHub Desktop.
University of Potsdam WLAN-over-VPN wrapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# University of Potsdam WLAN-over-VPN wrapper | |
VPNUSER=$(read -p "Username:") | |
#VPNUSER=johndoe | |
WLANIFACE=wlan0 | |
VPNIFACE=zeik.tun0 | |
# kill all remaining Cisco AnyConnect VPNs | |
pkill openconnect | |
[ "x$1" = "xstop" ] && exit 1 | |
# determine hostname | |
essid=`iwgetid --raw $WLANIFACE` | |
case $essid in | |
"Uni-WLAN-Wohnheim") host=wh group=wohnheim-wlan ;; | |
"Universitaet Potsdam ZEIK") host=wlan group=WLAN ;; | |
*) host=ssl group=SSLVPN | |
ping -c 1 sslvpn.uni-potsdam.de || exit 1 ;; | |
esac | |
host=${host}vpn.uni-potsdam.de | |
# connect to the VPN | |
echo "Connecting to $host:$group..." | |
openconnect $host --user=$VPNUSER --authgroup=$group \ | |
--verbose --syslog --background --interface=$VPNIFACE \ | |
&& echo "Connected!" | |
# route all connections thru the VPN interface | |
if [ "$host" != "ssl" ]; then | |
route add default dev $VPNIFACE | |
else | |
route add uni-potsdam.de dev $VPNIFACE | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment