summaryrefslogtreecommitdiff
blob: ab2acef23f6515932adbf4727147982f5954f42c (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-wireless/bluez-utils/files/2.16/bluetooth.rc,v 1.2 2005/04/27 12:40:04 liquidx Exp $

UART_CONF="/etc/bluetooth/uart"

depend() {
	after coldplug
}

start_uarts() {
	[ -f /usr/sbin/hciattach -a -f ${UART_CONF} ] || return
	grep -v '^#' ${UART_CONF} | while read i; do
		/usr/sbin/hciattach $i
	done		
}

stop_uarts() {
	killall hciattach > /dev/null 2>&1
}

start() {
   	ebegin "Starting Bluetooth"

	if [ "${HID2HCI_ENABLE}" = "true" -a -x /usr/sbin/hid2hci ]; then
		ebegin "    Running hid2hci"
		/usr/sbin/hid2hci -0 -q    #be quiet
		/bin/sleep 1 # delay for hid's to be detected by hotplug
		eend $?
	fi

	if [ "${HCID_ENABLE}" = "true" -a -x /usr/sbin/hcid ]; then
		if [ -f "${HCID_CONFIG}" ]; then
			ebegin "    Starting hcid"
			start-stop-daemon --start --quiet \
				--exec /usr/sbin/hcid -- -f $HCID_CONFIG
			eend $?
	    else
			ewarn "Not enabling hcid because HCID_CONFIG is missing."
	    fi
	fi
	

	if [ "${SDPD_ENABLE}" = "true" -a -x /usr/sbin/sdpd ]; then
		ebegin "    Starting sdpd"
		start-stop-daemon --start --quiet --exec /usr/sbin/sdpd
		eend $?
	fi

	
	if [ "${HIDD_ENABLE}" = "true" -a -x /usr/bin/hidd ]; then
		ebegin "    Starting hidd"
		start-stop-daemon --start --quiet \
			--exec /usr/bin/hidd -- ${HIDD_OPTIONS} --server
		eend $?
	fi

	if [ "${RFCOMM_ENABLE}" = "true" -a -x /usr/bin/rfcomm ]; then
		if [ -f "${RFCOMM_CONFIG}" ]; then
			ebegin "    Starting rfcomm"
			/usr/bin/rfcomm -f ${RFCOMM_CONFIG} bind all
			eend $?
		else
			ewarn "Not enabling rfcomm because RFCOMM_CONFIG does not exists"
		fi
	fi

	if [ "${DUND_ENABLE}" = "true" -a -x /usr/bin/dund ]; then
		if [ -n "${DUND_OPTIONS}" ]; then
			ebegin "    Starting dund"
			start-stop-daemon --start --quiet \
				--exec /usr/bin/dund -- ${DUND_OPTIONS}
			eend $?
		else
			ewarn "Not starting dund because DUND_OPTIONS not defined."
		fi
	fi

	if [ "${PAND_ENABLE}" = "true" -a -x /usr/bin/pand ]; then
		if [ -n "${PAND_OPTIONS}" ]; then
			ebegin "    Starting pand"
			start-stop-daemon --start --quiet \
				--exec /usr/bin/pand -- ${PAND_OPTIONS}
			eend $?
		else
			ewarn "Not starting pand because PAND_OPTIONS not defined."
		fi
	fi

	start_uarts
	eend 0
}
	
stop() {
	ebegin "Shutting down Bluetooth"


	if [ "${PAND_ENABLE}" = "true" -a -x /usr/bin/pand ]; then
		ebegin "    Stopping pand"
		start-stop-daemon --stop --quiet --exec /usr/bin/pand
		eend $?
	fi

	if [ "${DUND_ENABLE}" = "true" -a -x /usr/bin/dund ]; then
		ebegin "    Stopping dund"
		start-stop-daemon --stop --quiet --exec /usr/bin/dund
		eend $?
	fi

	if [ "${RFCOMM_ENABLE}" = "true" -a -x /usr/bin/rfcomm ]; then
		ebegin "    Stopping rfcomm"
		/usr/bin/rfcomm release all
		eend $?
	fi

	if [ "${HIDD_ENABLE}" = "true" -a -x /usr/bin/hidd ]; then
		ebegin "    Stopping hidd"
		start-stop-daemon --stop --quiet --exec /usr/bin/hidd
		eend $?	
	fi


	if [ "${SDPD_ENABLE}" = "true" -a -x /usr/sbin/sdpd ]; then
		ebegin "    Stopping sdpd"
		start-stop-daemon --stop --quiet --exec /usr/sbin/sdpd
		eend $?
	fi

	if [ "${HCID_ENABLE}" = "true" -a -x /usr/sbin/hcid ]; then
		ebegin "    Stopping hcid"
		start-stop-daemon --stop --quiet --exec /usr/sbin/hcid
		eend $?
	fi
		
	stop_uarts
	eend 0
}

restart() {
	svc_stop
	svc_start
}