blob: caea1dad7a6d8e050a43838e68f64867ee40a06f (
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
38
39
40
41
42
43
44
45
46
47
48
49
|
#!/bin/sh
#
# Format:
# bridge=<bridgename>:<bridgeslaves>
#
# <bridgeslaves> is a comma-separated list of physical (ethernet) interfaces
# bridge without parameters assumes bridge=br0:eth0
#
parsebridge() {
local v="${1}":
set --
while [ -n "$v" ]; do
set -- "$@" "${v%%:*}"
v=${v#*:}
done
case $# in
0)
bridgename=br0
bridgeslaves=$iface
;;
1) die "bridge= requires two parameters" ;;
2)
bridgename=$1
bridgeslaves=$(str_replace "$2" "," " ")
;;
*) die "bridge= requires two parameters" ;;
esac
}
# Parse bridge for bridgename and bridgeslaves
for bridge in $(getargs bridge=); do
unset bridgename
unset bridgeslaves
iface=eth0
# Read bridge= parameters if they exist
if [ "$bridge" != "bridge" ]; then
parsebridge "$bridge"
fi
# Simple default bridge
if [ -z "$bridgename" ]; then
bridgename=br0
bridgeslaves=$iface
fi
{
echo "bridgename=$bridgename"
echo "bridgeslaves=\"$bridgeslaves\""
} > /tmp/bridge.${bridgename}.info
done
|