tagged release 0.3.2
[vpnc.git] / vpnc-disconnect
blobd60f18c68c24c121cbbb5c816b33386678d09b9a
1 #!/bin/sh
3 defr=/var/run/vpnc/defaultroute
4 gateway=/var/run/vpnc/gateway
5 pid=/var/run/vpnc/pid
7 if [ $# -ne 0 ]; then
8 echo "Usage: $0" 1>&2
9 exit 1
12 PID="$(cat "$pid" 2> /dev/null)"
14 if [ -z "$PID" ]; then
15 echo "no vpnc found running"
16 exit 1
19 if ! kill -0 "$PID" > /dev/null 2>&1; then
20 echo "no vpnc found running"
21 exit 1
24 echo "Terminating vpnc daemon (pid: $PID)"
25 kill $PID
27 # this still sucks. Invent something to sync route removal/addition with
28 # vpnc-connect
30 if [ -s "$defr" ]; then
31 ip route del default > /dev/null 2>&1
32 ip route add $(cat "$defr")
33 test -r "$gateway" && ip route del $(cat "$gateway")
34 ip route flush cache
37 rm -f -- "$defr" "$pid" "$gateway"
39 exit 0