summaryrefslogtreecommitdiffstats
path: root/init.d/bridge
blob: bfbf0575765b2e0917f452b50fbf1464e96a8a85 (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
#!/sbin/runscript

BRCTL=`which brctl 2>/dev/null`

start() {
	# abort if brctl does not exist
	for brspec in $BRIDGES; do
		retcode=0
		br=`echo $brspec | cut -d= -f1`
		ebegin "Setting up bridge $br"
		if [ -z "$BRCTL" ] ; then
			eerror "Need bridge-utils to be able to set up $br"
			retcode=1
		else
			brctl addbr $br || retcode=1
			bridge_ifs=`echo "$BRIDGES"  | sed 's/.*=//; s/\+/ /g'` 
			for iface in $bridge_ifs ; do
				# set if in promisc mode
				ifconfig $iface 0.0.0.0 promisc up || retcode=1
				brctl addif $br $iface || retcode=1
			done
		fi
		eend $retcode
	done

}

stop() {
	which brctl > /dev/null 2>&1 || return 1
	for brspec in $BRIDGES; do
		br=`echo $brspec | cut -d= -f1`
		ebegin "Shutting down bridge $br"
		brctl delbr $br
		eend $?
	done
	

}