summaryrefslogtreecommitdiff
blob: 388e47356321e9a1e4eb09e3723910095b67c24a (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
#!/sbin/runscript

depend() {
	use modules
}

start() {
	for b in ${bridge}
	do
		ebegin "Create Bridge ${b}"
		/sbin/brctl addbr ${b} || {
			retval=$?
			eend ${retval} "Failed to create bridge ${b}"
			continue
		}
		for i in $(eval echo \$\{bridge_${b}_devices\})
		do
			/sbin/brctl addif ${b} ${i} || {
				retval=$?
				eend ${retval} "Failed to add interface ${i}"
				continue
			}
			ifconfig ${i} 0.0.0.0 promisc || \
				eend $? "Failed to set up interface ${i}"
		done
	done
}

stop() {
	for b in ${bridge}
	do
		ebegin "Destroy Bridge ${b}"
		for i in $(eval echo \$\{bridge_${b}_devices\})
		do
			ifconfig ${i} down || \
				eend $? "Failed to set down interface ${i}"
			/sbin/brctl delif ${b} ${i} || {
				retval=$?
				eend ${retval} "Failed to del interface ${i}"
				return ${retval}
			}
		done
		/sbin/brctl delbr ${b} || \
			eend ${retval} "Failed to destroy bridge ${b}"
	done
	eend $? "Failed to stop bridge"
}