summaryrefslogtreecommitdiff
path: root/etc/rc.d/btdevctl
blob: 4a0212f4936314f970016bdc9f24540a1f01c3fa (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
#!/bin/sh
#
# $NetBSD: btdevctl,v 1.4 2007/07/23 18:06:56 plunky Exp $
#

# PROVIDE: btdevctl
# REQUIRE: bluetooth bthcid
# BEFORE:  LOGIN

$_rc_subr_loaded . /etc/rc.subr

name="btdevctl"
rcvar=${name}
required_files="/etc/bluetooth/btdevctl.conf"
start_cmd='do_btdevctl "-A" "Attaching"'
stop_cmd='do_btdevctl "-D" "Detaching"'

do_btdevctl()
{
	echo "${2} Bluetooth devices:"

	while read -r service address device junk; do
		case ${service} in
		\#*|"")
			continue
			;;
		esac

		if [ -z ${device} -o ${junk} ]; then
			echo "${name}: invalid entry"
			return 1
		fi

		/usr/sbin/btdevctl ${1} "-a" ${address} "-d" ${device} "-s" ${service}
	done < /etc/bluetooth/btdevctl.conf
}

load_rc_config ${name}
run_rc_command "$1"