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