summaryrefslogtreecommitdiff
path: root/package/base-files/src/etc/network/if-pre-up.d/03-bridge
blob: 9bdbf8302acbd34560182f652370bcaf2de6ae84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh

[ -x /usr/sbin/brctl ] || exit 0

case "$IF_BRIDGE_PORTS" in
    "")
        exit 0
        ;;
    none)
        INTERFACES=""
        ;;
    *)
        INTERFACES="$IF_BRIDGE_PORTS"
        ;;
esac

brctl addbr $IFACE || exit 1
[[ -n $IF_BRIDGE_FD ]] && brctl setfd $IFACE $IF_BRIDGE_FD

for IF in $INTERFACES; 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

exit 0