#!/bin/sh
# ifupdown hook script for enhanced MadWifi (madwifi-ng) support in
# Debian and Debian-based distributions
#
# $Id: madwifi 24 2006-09-26 07:39:54Z mrenzmann $
#
# Copyright (c) 2006 Michael Renzmann <mrenzmann@otaku42.de>
# Portions Copyright (c) 2005 Matt Brown <matt@mattb.net.nz>
#
# For further information see:
# http://projects.otaku42.de/wiki/madwifi-ifupdown
#
# This is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License version 2 as published by the Free
# Software Foundation.
#
# This is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# the madwifi-ifupdown package; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
LIBDIR=@LIBDIR@
if [ ! -d "$LIBDIR" ]; then
	echo "ERROR: $LIBDIR: no such directory"
	exit 1
fi

if [ ! -f $LIBDIR/defaults ]; then
	echo "ERROR: $LIBDIR/defaults: no such file"
	exit 1
fi
. $LIBDIR/defaults

if [ ! -f "$LIBDIR/functions.inc.sh" ]; then
	echo "ERROR: unable to load functions.inc.sh" >&2
	exit 1
fi
. $LIBDIR/functions.inc.sh


[ -x "$WLANCONFIG" ] || exit 0
[ -x "$IFCONFIG" ] || exit 0

[ -n "$IF_ATH_PARENT" ] || exit 0

if [ "$VERBOSITY" -eq "0" ]; then
	exec 1>/dev/null
fi


if $IFCONFIG $IFACE &>/dev/null; then
	$WLANCONFIG $IFACE destroy || \
		error "failed to destroy $IFACE"
fi

# that's all, folks!
exit 0
