]> git.pld-linux.org Git - packages/bluez.git/blob - bluez.init
- no more hcid binary: remove start/stop parts, reload bluetoothd (kills it
[packages/bluez.git] / bluez.init
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
15 UART_CONF="/etc/bluetooth/uart"
16 [ -f /etc/sysconfig/bluetooth ] && . /etc/sysconfig/bluetooth
17
18 if [ "$UART_CONF" != "no" -a ! -f "$UART_CONF" ]; then
19         UART_CONF="no"
20 fi
21
22 start() {
23         # Check if the service is already running?
24         if [ ! -f /var/lock/subsys/bluetooth ]; then
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
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 "${HIDD_ENABLE}" && [ -x /usr/bin/hidd ]; then
39                         msg_starting hidd
40                         daemon /usr/bin/hidd ${HIDD_OPTIONS} --server
41                         RETVAL=$?
42                 fi
43
44                 if is_yes "${RFCOMM_ENABLE}" && [ -x /usr/bin/rfcomm ]; then
45                         msg_starting rfcomm
46                         daemon /usr/bin/rfcomm -f /etc/bluetooth/rfcomm.conf bind all
47                         RETVAL=$?
48                 fi
49
50                 if is_yes "${DUND_ENABLE}" && [ -x /usr/bin/dund ]; then
51                         msg_starting dund
52                         daemon /usr/bin/dund ${DUND_OPTIONS}
53                         RETVAL=$?
54                 fi
55
56                 if is_yes "${PAND_ENABLE}" && [ -x /usr/bin/pand ]; then
57                         msg_starting pand
58                         daemon /usr/bin/pand ${PAND_OPTIONS}
59                         RETVAL=$?
60                 fi
61
62                 if [ -f /usr/sbin/hciattach -a "$UART_CONF" != "no" ]; then
63                         grep -v '^#' $UART_CONF | while read i; do
64                                 /usr/sbin/hciattach $i
65                         done
66                 fi
67                 touch /var/lock/subsys/bluetooth
68         else
69                 msg_already_running bluetooth
70         fi
71 }
72
73 stop() {
74         if [ -f /var/lock/subsys/bluetooth ]; then
75                 if is_yes "${PAND_ENABLE}" && [ -x /usr/bin/pand ]; then
76                         msg_stopping pand
77                         killproc /usr/bin/pand
78                 fi
79
80                 if is_yes "${DUND_ENABLE}" && [ -x /usr/bin/dund ]; then
81                         msg_stopping dund
82                         killproc /usr/bin/dund
83                 fi
84
85                 if is_yes "${RFCOMM_ENABLE}" && [ -x /usr/bin/rfcomm ]; then
86                         msg_stopping rfcomm
87                         daemon /usr/bin/rfcomm release all
88                 fi
89
90                 if is_yes "${HIDD_ENABLE}" && [ -x /usr/bin/hidd ]; then
91                         msg_stopping hidd
92                         killproc /usr/bin/hidd
93                 fi
94
95                 if is_yes "${DAEMON_ENABLE}" && [ -x /usr/sbin/bluetoothd ]; then
96                         msg_stopping bluetooth
97                         killproc /usr/sbin/bluetoothd
98                 fi
99
100                 if [ "$UART_CONF" != "no" ]; then
101                         killproc hciattach >/dev/null 2>&1
102                 fi
103                 rm -f /var/lock/subsys/bluetooth
104         else
105                 msg_not_running bluetooth
106         fi
107 }
108
109 condrestart() {
110         if [ -f /var/lock/subsys/bluetooth ]; then
111                 stop
112                 start
113         else
114                 msg_not_running bluetooth
115                 RETVAL=$1
116         fi
117 }
118
119 RETVAL=0
120 # See how we were called.
121 case "$1" in
122   start)
123         start
124         ;;
125   stop)
126         stop
127         ;;
128   restart)
129         stop
130         start
131         ;;
132   try-restart)
133         condrestart 0
134         ;;
135   reload|force-reload)
136         if [ -f /var/lock/subsys/bluetooth ]; then
137                 msg_reloading bluetoothd
138                 killproc bluetoothd -HUP
139                 RETVAL=$?
140         else
141                 msg_not_running bluetooth
142                 exit 7
143         fi
144         ;;
145   status)
146         is_yes "${HID2HCI_ENABLE}" && status hid2hci
147         is_yes "${HCID_ENABLE}" && status bluetoothd
148         is_yes "${HIDD_ENABLE}" && status hidd
149         is_yes "${DUND_ENABLE}" && status dund
150         is_yes "${PAND_ENABLE}" && status pand
151         if [ -f /var/lock/subsys/bluetooth ]; then
152                 exit 0
153         else
154                 exit 1
155         fi
156         ;;
157   *)
158         msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
159         exit 3
160 esac
161
162 exit $RETVAL
This page took 0.073081 seconds and 4 git commands to generate.