]> Pileus Git - ~andy/sunrise/blob - net-wireless/bluez-utils/files/bluez-utils-3.10-init.d-hcid
net-wireless/bluez-utils: import from portage, split init script see bug #178210
[~andy/sunrise] / net-wireless / bluez-utils / files / bluez-utils-3.10-init.d-hcid
1 #!/sbin/runscript
2 # Copyright 1999-2007 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4 # $Header: $
5
6 UART_CONF="/etc/bluetooth/uart"
7
8 depend() {
9         after coldplug
10         need dbus
11 }
12
13 start_uarts() {
14         [ -f /usr/sbin/hciattach -a -f ${UART_CONF} ] || return
15         grep -v '^#' ${UART_CONF} | while read i; do
16                 /usr/sbin/hciattach $i
17         done
18 }
19
20 stop_uarts() {
21         killall hciattach > /dev/null 2>&1
22 }
23
24 start() {
25         if [ "${HID2HCI_ENABLE}" = "true" ]; then
26                 ebegin "Switch from HID to HCI mode"
27                 /usr/sbin/hid2hci -0 -q    #be quiet
28                 /bin/sleep 1 # delay for hid's to be detected by hotplug
29                 eend $?
30         fi
31
32         if [ -f "${HCID_CONFIG}" ]; then
33                 ebegin "Starting hcid"
34                 start-stop-daemon --start --quiet \
35                         --exec /usr/sbin/hcid -- -f $HCID_CONFIG
36                 eend $?
37         else
38                 eerror "Not enabling hcid because HCID_CONFIG is missing."
39         fi
40
41         start_uarts
42         eend 0
43 }
44
45 stop() {
46         #FIXME: doesn't work
47         #if [ "${HID2HCI_ENABLE}" = "true" ]; then
48         #       ebegin "Switch from HCI to HID mode"
49         #       /usr/sbin/hid2hci -1 -q    #be quiet
50         #       /bin/sleep 1 # delay for hid's to be detected by hotplug
51         #       eend $?
52         #fi
53         ebegin "Stopping hcid"
54         start-stop-daemon --stop --quiet --exec /usr/sbin/hcid
55         eend $?
56         stop_uarts
57         eend 0
58 }
59