#!/bin/bash
# $Id: ifdown-local,v 1.3 2004/02/02 14:19:14 bwhittak Exp $
#  (C) Copyright Network Associates Inc. 2002
#
# Called by /etc/sysconfig/network-scripts/ifdown-post after bringing device
# down

shopt -s extglob

PATH=/sbin:/usr/sbin:$PATH

dev=$1

ibr()
{
    ifconfig $1 down 2>/dev/null

    # remove the transparency driver
    /sbin/rmmod -r wsnat > /dev/null 2>&1

    # delete the bridge
    # man page says NICS's must be down before bridge is deleted
    # (even although they have been deleted from the bridge)
    # if we don't down the NIC's we get a kernel panic
    brctl delif $1 eth0
    brctl delif $1 eth1
    ifconfig eth0 down
    ifconfig eth1 down
    brctl delbr $1

    # remove the bridge module
    /sbin/rmmod bridge > /dev/null 2>&1
}

case $dev in
    (ibr*([0-9])) ibr $dev;;
esac
