rendered paste body#!/bin/sh
# ifdown-swisss.sh
if ! [ -f /root/swissvpn-logfile ]; then
IFACE=eth0
TUNFACE=ppp0
GATEWAY=129.82.68.1
echo "No log file found, routing table cannot be fully cleaned."
echo "To return routing table to pre-vpn settings, reload the routing configuration."
[ -f /var/run/ppp-swiss.pid ] && kill `head -n 1 /var/run/ppp-swiss.pid`
route add default gw $GATEWAY 2>/dev/null
exit 0
fi
IFACE=eth0
TUNFACE=ppp0
REMOTE=`cat /root/swissvpn-logfile | grep remote | sed -e 's/[A-Za-z[:space:]]//g'`
GATEWAY=129.82.68.1
# Kill vpn link
echo "Closing the vpn link."
[ -f /var/run/ppp-swiss.pid ] && kill `head -n 1 /var/run/ppp-swiss.pid`
# Remove old logfile
[ -f /root/swissvpn-logfile ] && rm -rf /root/swissvpn-logfile
echo "Reverting the routing table to pre-vpn status."
# Remove route to old vpn gateway
route del -host $REMOTE/32 gw $GATEWAY dev $IFACE 2>/dev/null
# Remove the default route for the vpn
route del default $TUNFACE 2>/dev/null
# Add new default route
route add default gw $GATEWAY 2>/dev/null
# Remove vpn endpoints
for HOST in `host connect.swissvpn.net | awk '{print $NF}'`; do
echo "Removing explicit entry for $HOST from the routing table."
route del -host $HOST gw $GATEWAY dev $IFACE 2>/dev/null
done