]> git.pld-linux.org Git - packages/bluez.git/blame - bluez.init
- from bluez-utils
[packages/bluez.git] / bluez.init
CommitLineData
c874b005
AM
1#!/bin/sh
2#
3# bluetooth Bluetooth subsystem starting and stopping
4#
5# chkconfig: 345 25 90
6#
7# description: Bluetooth subsystem
8#
9# $Id$
10
11
12# Source function library
13. /etc/rc.d/init.d/functions
14
15UART_CONF="/etc/bluetooth/uart"
16[ -f /etc/sysconfig/bluetooth ] && . /etc/sysconfig/bluetooth
17
18if [ "$UART_CONF" != "no" -a ! -f "$UART_CONF" ]; then
19 UART_CONF="no"
20fi
21
22start() {
23 # Check if the service is already running?
24 if [ ! -f /var/lock/subsys/bluetooth ]; then
25 msg_starting bluetooth; started
26 if is_yes "${HID2HCI_ENABLE}" && [ -x /usr/sbin/hid2hci ]; then
27 msg_starting hid2hci
28 daemon /usr/sbin/hid2hci -0 -q #be quiet
29 RETVAL=$?
30 /bin/sleep 1 # delay for hid's to be detected by hotplug
31 fi
32
33 if is_yes "${HCID_ENABLE}" && [ -x /usr/sbin/hcid ]; then
34 HCID_FLAGS="-f /etc/bluetooth/hcid.conf"
35
36 if is_yes "${SDPD_ENABLE}" ; then
37 HCID_FLAGS="$HCID_FLAGS -s"
38 fi
39 msg_starting hcid
40 daemon /usr/sbin/hcid $HCID_FLAGS
41 RETVAL=$?
42 fi
43
44 if is_yes "${HIDD_ENABLE}" && [ -x /usr/bin/hidd ]; then
45 msg_starting hidd
46 daemon /usr/bin/hidd ${HIDD_OPTIONS} --server
47 RETVAL=$?
48 fi
49
50 if is_yes "${RFCOMM_ENABLE}" && [ -x /usr/bin/rfcomm ]; then
51 msg_starting rfcomm
52 daemon /usr/bin/rfcomm -f /etc/bluetooth/rfcomm.conf bind all
53 RETVAL=$?
54 fi
55
56 if is_yes "${DUND_ENABLE}" && [ -x /usr/bin/dund ]; then
57 msg_starting dund
58 daemon /usr/bin/dund ${DUND_OPTIONS}
59 RETVAL=$?
60 fi
61
62 if is_yes "${PAND_ENABLE}" && [ -x /usr/bin/pand ]; then
63 msg_starting pand
64 daemon /usr/bin/pand ${PAND_OPTIONS}
65 RETVAL=$?
66 fi
67
68 if [ -f /usr/sbin/hciattach -a "$UART_CONF" != "no" ]; then
69 grep -v '^#' $UART_CONF | while read i; do
70 /usr/sbin/hciattach $i
71 done
72 fi
73 touch /var/lock/subsys/bluetooth
74 else
75 msg_already_running bluetooth
76 fi
77}
78
79stop() {
80 if [ -f /var/lock/subsys/bluetooth ]; then
81 if is_yes "${PAND_ENABLE}" && [ -x /usr/bin/pand ]; then
82 msg_stopping pand
83 killproc /usr/bin/pand
84 fi
85
86 if is_yes "${DUND_ENABLE}" && [ -x /usr/bin/dund ]; then
87 msg_stopping dund
88 killproc /usr/bin/dund
89 fi
90
91 if is_yes "${RFCOMM_ENABLE}" && [ -x /usr/bin/rfcomm ]; then
92 msg_stopping rfcomm
93 daemon /usr/bin/rfcomm release all
94 fi
95
96 if is_yes "${HIDD_ENABLE}" && [ -x /usr/bin/hidd ]; then
97 msg_stopping hidd
98 killproc /usr/bin/hidd
99 fi
100
101 if is_yes "${HCID_ENABLE}" && [ -x /usr/sbin/hcid ]; then
102 msg_stopping hcid
103 killproc /usr/sbin/hcid
104 fi
105
106 if [ "$UART_CONF" != "no" ]; then
107 killproc hciattach >/dev/null 2>&1
108 fi
109 rm -f /var/lock/subsys/bluetooth
110 else
111 msg_not_running bluetooth
112 fi
113}
114
115RETVAL=0
116# See how we were called.
117case "$1" in
118 start)
119 start
120 ;;
121 stop)
122 stop
123 ;;
124 restart)
125 stop
126 start
127 ;;
128 reload|force-reload)
129 if [ -f /var/lock/subsys/bluetooth ]; then
130 msg_reloading hcid
131 killproc hcid -HUP
132 RETVAL=$?
133 else
134 msg_not_running bluetooth
135 exit 7
136 fi
137 ;;
138 status)
139 is_yes "${HID2HCI_ENABLE}" && status hid2hci
140 is_yes "${HCID_ENABLE}" && status hcid
141 is_yes "${SDPD_ENABLE}" && status sdpd
142 is_yes "${HIDD_ENABLE}" && status hidd
143 is_yes "${DUND_ENABLE}" && status dund
144 if [ -f /var/lock/subsys/bluetooth ]; then
145 exit 0
146 else
147 exit 1
148 fi
149 ;;
150 *)
151 msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
152 exit 3
153esac
154
155exit $RETVAL
This page took 0.040345 seconds and 4 git commands to generate.