#!/bin/bash
DEFAULT_VPN_NAME="AlgoVPN algo3"












export PATH=$PATH:/usr/bin/local

VPN_NAME=$1
if [[ $VPN_NAME = "" ]];
then
  VPN_NAME=$DEFAULT_VPN_NAME
fi

curStatus=$( /usr/sbin/networksetup -showpppoestatus "${VPN_NAME}" )
dtst=`date +"%Y%m%d-%H.%M"`

echo ""
echo "Script:"
echo "vpn flip for ${VPN_NAME}"
echo "------------------------------------------------------------------------"
echo "Machine:" $cname
/usr/bin/sw_vers
sysctl kern.version
sysctl kern.ostype
sysctl kern.osrelease
sysctl kern.osrevision
echo ""

if [[ $curStatus = "disconnected" ]];
then
  echo "Currently disconnected, connecting..."
  /usr/sbin/networksetup -connectpppoeservice "${VPN_NAME}"
else
  echo "Currently connected, disconnecting..."
  /usr/sbin/networksetup -disconnectpppoeservice "${VPN_NAME}"
fi
