#!/bin/sh

[ "$IF_BRIDGE_IFACES" = "" ] && exit 0

grep -q $IFACE /proc/net/dev && exit 0

brctl addbr $IFACE
for IF in $IF_BRIDGE_IFACES; do
	if ! grep -q $IF /proc/net/dev; then
		echo "Error: interface '$IF' does not exist!"
		brctl delbr $IFACE
		exit 1
	fi
	brctl addif $IFACE $IF
	ip link set up dev $IF
done

# BUGFIX for bridged wireless lan
[ -f /var/run/nas.lan.cmd ] && (cd /var/run; kill `cat nas.lan.pid` || killall nas ; sleep 5 ; sh nas.lan.cmd)
exit 0

