#!/bin/sh # 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, brings up the related # bridge set -e if [ -z "$INTERFACE" ]; then echo "missing \$INTERFACE" >&2 exit 1 fi . /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.*) if [ ! -d /sys/class/net/$port ] && [ -x /etc/network/if-pre-up.d/vlan ]; then IFACE=$port /etc/network/if-pre-up.d/vlan fi if [ -d /sys/class/net/$port ]; then ifup --allow auto $i brctl addif $i $port && ifconfig $port 0.0.0.0 up fi break ;; esac done done