blob: 489a2fcad55e2fd76d7992e0ea81b1d0d935e6f6 (
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
31
32
33
34
35
36
37
|
#!/bin/sh
INTERFACES=""
BONDOPTS=""
for var in $(env | grep '^IF_BOND_'); do
val="${var#*=}"
opt="${var%%=*}"
if [ "$opt" == "IF_BOND_PORTS" ]; then
case "$val" in
none)
INTERFACES=""
;;
*)
INTERFACES="$val"
;;
esac
continue
fi
opt="$(tr '[A-Z]' '[a-z]' <<< ${opt#IF_BOND_})"
BONDOPTS+=" $opt"
[ -n "$val" ] && BONDOPTS+=" $val"
done
[ -n "$INTERFACES" ] || exit 0
ip link add $IFACE type bond ${BONDOPTS} || exit 1
for IF in $INTERFACES; do
if ! grep -q $IF /proc/net/dev; then
echo "Error: interface '$IF' does not exist!"
ip link del $IFACE
exit 1
fi
ip link set $IF master $IFACE
ip link set $IF up
done
exit 0
|