#!/bin/bash -e # if-post-down.d script to take down an ssh tunnel # Don Marti # Based on script for Postfix # by LaMont Jones LOCAL_PIDFILE=/var/run/tunnel-out.pid # don't bother when lo is configured. if [ "$IFACE" = "lo" ]; then exit 0 fi # Need to have /var mounted if [ ! -d /var/run ]; then exit 0 fi # Do we have a route to the outside? # If no then take down the tunnel. if ! /sbin/route -n | /bin/grep -q ^0.0.0.0 ; then /sbin/start-stop-daemon --stop \ --pidfile $LOCAL_PIDFILE fi