#!/bin/sh
########################################################
#                                                      #
# post-up script for vpnc                              #
#                                                      #
# Author: Christian Gogolin                   (2007)   #
#                                                      #
# This script is free software. You can redistribute   #
# it and/or modify it under the terms of the GNU       #
# General Public License as published by the Free      #
# Software Foundation; either version 2 of the         #
# License, or (at your option) any later version.      #
#                                                      #
# This script is distributed in the hope that it will  #
# be useful, but WITHOUT ANY WARRANTY; without even    #
# the implied warranty of MERCHANTABILITY or FITNESS   #
# FOR A PARTICULAR PURPOSE. See the GNU General Public #
# License for more details.                            #
#                                                      #
########################################################


ssid=`wpa_cli status | sed -n -e '/ssid/ s/^ssid=\(.*\)$/\1/p'`
ip_address=`wpa_cli status | sed -n -e '/ip_address/ s/^ip_address=\(.*\)$/\1/p'`

if [ $ssid ] && [ $ip_address ]; then 

    #establish vpn-connection if at university
    if [ $ssid = "RZUW" ]; then
	#start keepalive process in sub shell
	/etc/vpnc/vpnc-keepalive &
    fi
fi

exit 0