# bridge-network-interface - configure a network bridge
#
# This service checks whether a physical network device that has been added
# is one of the ports in a bridge config, and if so, bring up the related
# bridge

description	"configure bridges for device"

start on net-device-added
stop on net-device-removed INTERFACE=$INTERFACE

instance $INTERFACE

pre-start script
	. /lib/bridge-utils/bridge-utils.sh

	mkdir -p /var/run/network
	for i in $(ifquery --list --allow auto); do
		ports=$(ifquery $i | sed -n -e's/^bridge_ports: //p')
		for port in $(bridge_parse_ports $ports); do
			case $port in
				$INTERFACE|$INTERFACE.*)
					ifup --allow auto $i
					brctl addif $i $port && ifconfig $port 0.0.0.0 up
					break
					;;
			esac
		done
	done
end script
