#!/bin/sh

# You don't usually need to touch this file at all, the full configuration
# of the bridge can be done in a standard way on /etc/network/interfaces.

# Have a look at /usr/share/doc/bridge-utils/README.Debian.gz if you want
# more info about the way on wich a bridge is set up on Debian.

if [ -z "$IF_VLAN_RAW_DEVICE" ]
then
	exit 0
fi

if [ ! -x /sbin/vconfig ]
then
  exit 0
fi

if ! ip link show dev "$IF_VLAN_RAW_DEVICE" > /dev/null
then
	echo "$IF_VLAN_DEVICE does not exist"
	exit 1
fi

case "$IFACE" in
		vlan0*)
			vconfig set_name_type VLAN_PLUS_VID
			VLANID=`echo $IFACE|sed "s/vlan0*//g"`
			;;
		vlan*)
			vconfig set_name_type VLAN_PLUS_VID_NO_PAD
			VLANID=`echo $IFACE|sed "s/vlan0*//g"`
			;;
		eth*)
			vconfig set_name_type DEV_PLUS_VID_NO_PAD
			VLANID=`echo $IFACE|sed "s/eth[0-9][0-9]*\.0*//g"`
			;;
esac

vconfig add $IF_VLAN_RAW_DEVICE $VLANID
ip link set up dev $IF_VLAN_RAW_DEVICE
