summaryrefslogtreecommitdiff
blob: 445d2f1283f364bf5a4d5a6c895ef5d01a8571c9 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Copyright (c) 2004-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# Contributed by Roy Marples (uberlord@gentoo.org)

# void br2684ctl_depend(void)
br2684ctl_depend() {
	before ppp
}
br2684ctl_expose() {
	variables br2684ctl
}

# bool br2684ctl_check_installed(void)
br2684ctl_check_installed() {
	[[ -x /sbin/br2684ctl ]] && return 0
	${1:-false} && eerror "For RFC 2684 Bridge control support, emerge net-misc/br2684ctl"
	return 1
}

# bool br2684ctl_start(char *iface)
br2684ctl_pre_start() {
	local iface="$1" ifvar="$(bash_variable "$1")" opts=
	local number="${iface#${iface%%[0-9]}}"
	
	opts="br2684ctl_${ifvar}"
	[[ -z ${!opts} ]] && return 0

	if [[ $(interface_type "${iface}") != "nas" || -z ${number} ]] ; then
		eerror "interface must be called nas[0-9] for RFC 2684 Bridging"
		return 1
	fi
	
	if [[ " ${!opts} " != *" -a "* ]] ; then
		eerror "-a option (VPI and VCI) is required in br2684_ctl"
		return 1
	fi

	if [[ " ${!opts} " != *" -b "* ]] ; then
		eerror "The -b option is not allowed for br2684ctl_${ifvar}"
		return 1
	fi
	
	einfo "Starting RFC 2684 Bridge control on ${iface}"
	
	start-stop-daemon --start --exec /sbin/br2684ctl --background \
		--make-pidfile --pidfile "/var/run/br2684ctl-${iface}.pid" \
		-- ${!opts} -c "${number}"
	eend $?
}

# bool br2684ctl_post_stop(char *iface)
br2684ctl_post_stop() {
	local iface="$1"
	local number="${iface#${iface%%[0-9]}}"
	
	[[ $(itype "${iface}") != "nas" ]] && return 0
	
	[[ -e /var/run/br2864ctl-${iface}.pid ]] || return 0
	
	einfo "Stopping RFC 2684 Bridge control on ${iface}"
	start-stop-daemon --stop --exec /sbin/br2864ctl \
		--pidfile "/var/run/br2684ctl-${iface}.pid"
	eend $?
}

# vim: set ts=4 :