#!/bin/sh ################################################################################ # Most portions of this script shamelessly stolen from the original script # # provided with the vpnc project. Script has been fixed to work with FreeBSD # # and commented. # # # # Modifications by: Jason But 2004 # ################################################################################ ################################################################################ # Filenames where runtime database information is stored to be used by the # # corresponding vpnc-disconnect script. # ################################################################################ defr=/var/run/vpnc/defaultroute gateway=/var/run/vpnc/gateway pid=/var/run/vpnc/pid ################################################################################ # Usage: must be called with no parameters. # ################################################################################ if [ $# -ne 0 ]; then echo "Usage: $0" 1>&2 exit 1 fi ################################################################################ # Locate and kill any currently running vpnc daemon, terminate if it is not # # running. # ################################################################################ PID="$(cat "$pid" 2> /dev/null)" if [ -z "$PID" ]; then echo "no vpnc found running" exit 1 fi if ! kill -0 "$PID" > /dev/null 2>&1; then echo "no vpnc found running" exit 1 fi echo "Terminating vpnc daemon (pid: $PID)" kill $PID # this still sucks. Invent something to sync route removal/addition with # vpnc-connect ################################################################################ # Reapply the original routing table. # # - Delete the current default route (through tunnel - added by vpnc-connect # # - Add the original default route (route information in $defr) # # - Delete the static route to the gateway (gateway address in $gateway) # # Finally delete database files. # ################################################################################ echo "...Re-applying original Routing information" if [ -s "$defr" ]; then route delete default > /dev/null 2>&1 route add $(cat "$defr") test -r "$gateway" && route delete $(cat "$gateway") fi rm -f -- "$defr" "$pid" "$gateway" exit 0