aboutsummaryrefslogtreecommitdiff
blob: d8be2d5ecf0d1f19050731d54f133a2fce30e731 (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
# Original copyright (c) 2007-2009 Roy Marples <roy@marples.name>
# Released under the 2-clause BSD license.

iwd_depend()
{
	after macnet plug
	before interface
	provide wireless
	after iwconfig
	program iwd
}

_config_vars="$_config_vars iwd"

iwd_pre_start()
{
	local iwds=/usr/libexec/iwd
	local args= opt= opts=
	eval opts=\$iwd_${IFVAR}

	#set a "safe" default in case phy was not defined
	PHY="phy0"

	for opt in ${opts}; do
		case "${opt}" in
			phy* )	PHY="${opt}"
				einfo "Assigned PHY to be ${PHY}"
				;;
			*    )	;;
		esac
	done
	ebegin "Starting iwd on ${PHY} and ${IFVAR}"
	pidfile="/run/iwd-${IFVAR}.pid"
	start-stop-daemon --start --exec "${iwds}" --pidfile "${pidfile}" --background --verbose --make-pidfile -- -p ${PHY} -i "${IFVAR}"
	return $?
}


iwd_post_stop()
{
	local iwds=/usr/libexec/iwd
	pidfile="/run/iwd-${IFVAR}.pid"
	if [ -f ${pidfile} ]; then
		ebegin "Stopping iwd on ${IFACE}"
		start-stop-daemon --stop --exec "${iwds}" --pidfile "${pidfile}"
		eend $?
	fi

	# If iwd exits uncleanly, we need to remove the stale dir
	[ -S "/run/iwd/${IFACE}" ] \
		&& rm -f "/run/iwd/${IFACE}"
}