]>
Commit | Line | Data |
---|---|---|
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 | ||
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 | |
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 | |
a18a42aa | 33 | daemon /usr/sbin/hid2hci -0 -q # be quiet |
c874b005 AM |
34 | RETVAL=$? |
35 | /bin/sleep 1 # delay for hid's to be detected by hotplug | |
36 | fi | |
a18a42aa | 37 | |
c874b005 AM |
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 | |
a18a42aa | 49 | |
c874b005 AM |
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 | |
a18a42aa | 55 | |
c874b005 AM |
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 | ||
a18a42aa | 90 | if is_yes "${HIDD_ENABLE}" && [ -x /usr/bin/hidd ]; then |
c874b005 AM |
91 | msg_stopping hidd |
92 | killproc /usr/bin/hidd | |
93 | fi | |
c874b005 | 94 | |
ebcc455c PZ |
95 | if is_yes "${DAEMON_ENABLE}" && [ -x /usr/sbin/bluetoothd ]; then |
96 | msg_stopping bluetooth | |
97 | killproc /usr/sbin/bluetoothd | |
98 | fi | |
99 | ||
c874b005 AM |
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 | ||
c762e736 JB |
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 | ||
c874b005 AM |
119 | RETVAL=0 |
120 | # See how we were called. | |
121 | case "$1" in | |
122 | start) | |
a18a42aa | 123 | start |
c874b005 AM |
124 | ;; |
125 | stop) | |
a18a42aa | 126 | stop |
c874b005 AM |
127 | ;; |
128 | restart) | |
129 | stop | |
130 | start | |
131 | ;; | |
c762e736 JB |
132 | try-restart) |
133 | condrestart 0 | |
134 | ;; | |
c874b005 AM |
135 | reload|force-reload) |
136 | if [ -f /var/lock/subsys/bluetooth ]; then | |
a18a42aa TP |
137 | msg_reloading bluetoothd |
138 | killproc bluetoothd -HUP | |
c874b005 AM |
139 | RETVAL=$? |
140 | else | |
141 | msg_not_running bluetooth | |
142 | exit 7 | |
143 | fi | |
144 | ;; | |
145 | status) | |
146 | is_yes "${HID2HCI_ENABLE}" && status hid2hci | |
a18a42aa | 147 | is_yes "${HCID_ENABLE}" && status bluetoothd |
c874b005 AM |
148 | is_yes "${HIDD_ENABLE}" && status hidd |
149 | is_yes "${DUND_ENABLE}" && status dund | |
a18a42aa | 150 | is_yes "${PAND_ENABLE}" && status pand |
c874b005 AM |
151 | if [ -f /var/lock/subsys/bluetooth ]; then |
152 | exit 0 | |
153 | else | |
154 | exit 1 | |
a18a42aa | 155 | fi |
c874b005 AM |
156 | ;; |
157 | *) | |
c762e736 | 158 | msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}" |
c874b005 AM |
159 | exit 3 |
160 | esac | |
161 | ||
162 | exit $RETVAL |