#!/bin/bash


# conf file for your vpn, leave off the .conf ext
# Runs as root, so absolute path is necessary
vpncConfPath="/home/dino/doc/jobs/PAC/work/pac.vpnc"

device="tun0"


basename=`basename $0`


function usage {
   cat <<USAGE
$basename - Bring vpnc up or down

usage:
   $basename COMMAND

options:
   -h, --help  This help info

commands:
   up    Bring the vpn up
   down  Bring the vpn down

built-in params:

   vpncConfPath: $vpncConfPath
   device: $device

USAGE

   exit 1
}


function vpnAction {
   vpnc-disconnect
   resolvconf -d $device
   $*
   sleep 1
   ip addr show $device
}


case "$1" in
   up)   vpnAction vpnc $vpncConfPath ;;
   down) vpnAction ;;
   *)    usage ;;
esac
