#!/bin/sh
#
#	$Id: tnldown,v 1.14 2000/03/31 13:10:22 misiek Exp $
#
# Author: Arkadiusz Mikiewicz <misiek@pld.org.pl>
#

DEV=$1

[ -z "$DEV" ] && {
    echo "usage: tnlup <device name>" >&2
    exit 1
}

. /etc/sysconfig/network-scripts/.functions
. /etc/sysconfig/network

TNLCONFIGS="`ls /etc/sysconfig/interfaces/tnlcfg-*|egrep -v '~$'`"
TNLCONFIGS="`egrep -L '^#!' $TNLCONFIGS`"
CONFIG="`egrep -l "^DEVICE=[\"\']*$DEV[\"\']*\$" $TNLCONFIGS`"

if [ -z "$CONFIG" ]; then
    CONFIG="$DEV"
fi

if false; then
[ -f "/etc/sysconfig/interfaces/$CONFIG" ] || CONFIG=tnlcfg-$CONFIG
[ -f "/etc/sysconfig/interfaces/$CONFIG" ] || {
    echo "usage: tnlup <device name>" >&2
    exit 1
}
fi

source_config

[ "${IPV6_TUNNELCONFIG}" != "yes" -a "${MODE}" = "sit" ] && exit 0
[ "${IPX}" != "yes" -a "${MODE}" = "ipxip" ] && exit 0
[ "${IPX}" != "yes" -a "${MODE}" = "ipipx" ] && exit 0

if [ "${MODE}" = "ipip" ] || [ "${MODE}" = "sit" ] || [ "${MODE}" = "gre" ]; then

	ip tunnel del ${DEVICE}

elif [ "${MODE}" = "ipxip" ] || [ "${MODE}" = "ipipx" ]; then

echo "obsuga ipxip jeszcze nie zrobiona"

fi
