#!/bin/sh

. /etc/rc.common


# No arguemnts, print usage
case $# in
0)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
    ;;
esac


CISCO_VPN_DIR=/System/Library/Extensions/CiscoVPN.kext

StartService ()
{
    if [ -d $CISCO_VPN_DIR ]; then
        ConsoleMessage "Starting Cisco Systems VPN Driver"
        kextload $CISCO_VPN_DIR
    fi
}

StopService ()
{
    if [ -d $CISCO_VPN_DIR ]; then
        ConsoleMessage "Stopping Cisco Systems VPN Driver"
        kextunload $CISCO_VPN_DIR
    fi
}

RestartService () { StopService; StartService; }

#
# Load the VPN Driver here
#

if [ -f /var/run/resolv.conf.vpnbackup ]; then
    mv /var/run/resolv.conf.vpnbackup /var/run/resolv.conf
fi

# OS X 10.2 has /etc/rc.common:RunService() for this, but 10.1 does not
case $1 in
    start)      StartService   ;;
    stop)       StopService    ;;
    restart)    RestartService ;;
    *)          echo "Usage: $0 {start|stop|restart}" ;;
esac

