]> git.pld-linux.org Git - packages/bluez-utils.git/blame - bluez-utils.init
- too many apps starts here so one can fail, another can work, lock file would be...
[packages/bluez-utils.git] / bluez-utils.init
CommitLineData
967b575d
JB
1#!/bin/sh
2#
3# bluetooth Bluetooth subsystem starting and stopping
4#
79f13a51 5# chkconfig: 345 25 90
967b575d
JB
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
221d00b8 19 UART_CONF="no"
967b575d
JB
20fi
21
f45a2554 22start() {
967b575d
JB
23 # Check if the service is already running?
24 if [ ! -f /var/lock/subsys/bluetooth ]; then
5a541047
AM
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
f80a251c
JK
34 HCID_FLAGS="-f /etc/bluetooth/hcid.conf"
35
36 if is_yes "${SDPD_ENABLE}" ; then
37 HCID_FLAGS="$HCID_FLAGS -s"
38 fi
5a541047 39 msg_starting hcid
f80a251c 40 daemon /usr/sbin/hcid $HCID_FLAGS
5a541047
AM
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
967b575d 68 if [ -f /usr/sbin/hciattach -a "$UART_CONF" != "no" ]; then
221d00b8 69 grep -v '^#' $UART_CONF | while read i; do
70 /usr/sbin/hciattach $i
71 done
967b575d 72 fi
b326b778 73 touch /var/lock/subsys/bluetooth
967b575d 74 else
5a541047 75 msg_already_running bluetooth
967b575d 76 fi
f45a2554
ER
77}
78
79stop() {
967b575d 80 if [ -f /var/lock/subsys/bluetooth ]; then
5a541047
AM
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
967b575d 89 fi
5a541047
AM
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
5a541047
AM
101 if is_yes "${HCID_ENABLE}" && [ -x /usr/sbin/hcid ]; then
102 msg_stopping hcid
b79d0eb1 103 killproc /usr/sbin/hcid
5a541047
AM
104 fi
105
967b575d 106 if [ "$UART_CONF" != "no" ]; then
221d00b8 107 killproc hciattach >/dev/null 2>&1
967b575d
JB
108 fi
109 rm -f /var/lock/subsys/bluetooth
110 else
5a541047 111 msg_not_running bluetooth
c948d0b5 112 fi
f45a2554
ER
113}
114
115RETVAL=0
116# See how we were called.
117case "$1" in
118 start)
119 start
120 ;;
121 stop)
122 stop
967b575d
JB
123 ;;
124 restart)
f45a2554
ER
125 stop
126 start
967b575d 127 ;;
18c1a831 128 reload|force-reload)
967b575d 129 if [ -f /var/lock/subsys/bluetooth ]; then
5a541047 130 msg_reloading hcid
967b575d
JB
131 killproc hcid -HUP
132 RETVAL=$?
133 else
f45a2554 134 msg_not_running bluetooth
63e20b4e 135 exit 7
967b575d
JB
136 fi
137 ;;
967b575d 138 status)
5a541047
AM
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
e353b2cd
ER
144 if [ -f /var/lock/subsys/bluetooth ]; then
145 exit 0
146 else
147 exit 1
148 fi
79f13a51 149 ;;
967b575d 150 *)
79f13a51 151 msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
18c1a831 152 exit 3
967b575d
JB
153esac
154
155exit $RETVAL
This page took 0.046336 seconds and 4 git commands to generate.