]> git.pld-linux.org Git - packages/bluez-utils.git/blame - bluez-utils.init
Typo
[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
7ac3ca54 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
34 msg_starting hcid
35 daemon /usr/sbin/hcid -f /etc/bluetooth/hcid.conf
36 RETVAL=$?
37 fi
38
39 if is_yes "${SDPD_ENABLE}" && [ -x /usr/sbin/sdpd ]; then
40 msg_starting sdpd
41 daemon /usr/sbin/sdpd
42 RETVAL=$?
43 fi
44
45 if is_yes "${HIDD_ENABLE}" && [ -x /usr/bin/hidd ]; then
46 msg_starting hidd
47 daemon /usr/bin/hidd ${HIDD_OPTIONS} --server
48 RETVAL=$?
49 fi
50
51 if is_yes "${RFCOMM_ENABLE}" && [ -x /usr/bin/rfcomm ]; then
52 msg_starting rfcomm
53 daemon /usr/bin/rfcomm -f /etc/bluetooth/rfcomm.conf bind all
54 RETVAL=$?
55 fi
56
57 if is_yes "${DUND_ENABLE}" && [ -x /usr/bin/dund ]; then
58 msg_starting dund
59 daemon /usr/bin/dund ${DUND_OPTIONS}
60 RETVAL=$?
61 fi
62
63 if is_yes "${PAND_ENABLE}" && [ -x /usr/bin/pand ]; then
64 msg_starting pand
65 daemon /usr/bin/pand ${PAND_OPTIONS}
66 RETVAL=$?
67 fi
68
967b575d 69 if [ -f /usr/sbin/hciattach -a "$UART_CONF" != "no" ]; then
221d00b8 70 grep -v '^#' $UART_CONF | while read i; do
71 /usr/sbin/hciattach $i
72 done
967b575d 73 fi
967b575d
JB
74 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/bluetooth
75 else
5a541047 76 msg_already_running bluetooth
967b575d 77 fi
7ac3ca54
ER
78}
79
80stop() {
967b575d 81 if [ -f /var/lock/subsys/bluetooth ]; then
5a541047
AM
82 if is_yes "${PAND_ENABLE}" && [ -x /usr/bin/pand ]; then
83 msg_stopping pand
84 killproc /usr/bin/pand
85 fi
86
87 if is_yes "${DUND_ENABLE}" && [ -x /usr/bin/dund ]; then
88 msg_stopping dund
89 killproc /usr/bin/dund
967b575d 90 fi
5a541047
AM
91
92 if is_yes "${RFCOMM_ENABLE}" && [ -x /usr/bin/rfcomm ]; then
93 msg_stopping rfcomm
94 daemon /usr/bin/rfcomm release all
95 fi
96
97 if is_yes "${HIDD_ENABLE}" && [ -x /usr/bin/hidd ]; then
98 msg_stopping hidd
99 killproc /usr/bin/hidd
100 fi
101
102 if is_yes "${SDPD_ENABLE}" && [ -x /usr/sbin/sdpd ]; then
103 msg_stopping sdpd
104 killproc /usr/sbin/sdpd
105 fi
106
107 if is_yes "${HCID_ENABLE}" && [ -x /usr/sbin/hcid ]; then
108 msg_stopping hcid
b79d0eb1 109 killproc /usr/sbin/hcid
5a541047
AM
110 fi
111
967b575d 112 if [ "$UART_CONF" != "no" ]; then
221d00b8 113 killproc hciattach >/dev/null 2>&1
967b575d
JB
114 fi
115 rm -f /var/lock/subsys/bluetooth
116 else
5a541047 117 msg_not_running bluetooth
c948d0b5 118 fi
7ac3ca54
ER
119}
120
121RETVAL=0
122# See how we were called.
123case "$1" in
124 start)
125 start
126 ;;
127 stop)
128 stop
967b575d
JB
129 ;;
130 restart)
7ac3ca54
ER
131 stop
132 start
967b575d 133 ;;
18c1a831 134 reload|force-reload)
967b575d 135 if [ -f /var/lock/subsys/bluetooth ]; then
5a541047 136 msg_reloading hcid
967b575d
JB
137 killproc hcid -HUP
138 RETVAL=$?
139 else
7ac3ca54 140 msg_not_running bluetooth
63e20b4e 141 exit 7
967b575d
JB
142 fi
143 ;;
967b575d 144 status)
5a541047
AM
145 is_yes "${HID2HCI_ENABLE}" && status hid2hci
146 is_yes "${HCID_ENABLE}" && status hcid
147 is_yes "${SDPD_ENABLE}" && status sdpd
148 is_yes "${HIDD_ENABLE}" && status hidd
149 is_yes "${DUND_ENABLE}" && status dund
63e20b4e 150 exit $?
79f13a51 151 ;;
967b575d 152 *)
79f13a51 153 msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
18c1a831 154 exit 3
967b575d
JB
155esac
156
157exit $RETVAL
This page took 0.076118 seconds and 4 git commands to generate.