]>
Commit | Line | Data |
---|---|---|
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 | ||
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 | |
221d00b8 | 19 | UART_CONF="no" |
967b575d JB |
20 | fi |
21 | ||
18c1a831 | 22 | RETVAL=0 |
967b575d JB |
23 | # See how we were called. |
24 | case "$1" in | |
25 | start) | |
26 | # Check if the service is already running? | |
27 | if [ ! -f /var/lock/subsys/bluetooth ]; then | |
967b575d JB |
28 | msg_starting Bluetooth |
29 | if [ -f /usr/sbin/hciattach -a "$UART_CONF" != "no" ]; then | |
221d00b8 | 30 | grep -v '^#' $UART_CONF | while read i; do |
31 | /usr/sbin/hciattach $i | |
32 | done | |
967b575d JB |
33 | fi |
34 | daemon /usr/sbin/hcid -f /etc/bluetooth/hcid.conf | |
35 | RETVAL=$? | |
36 | if [ $RETVAL -ne 0 ]; then | |
221d00b8 | 37 | killproc hciattach >/dev/null 2>&1 |
967b575d | 38 | elif [ -x /usr/sbin/sdpd ]; then |
221d00b8 | 39 | msg_starting "Bluetooth SDP" |
40 | daemon /usr/sbin/sdpd | |
41 | RETVAL=$? | |
42 | if [ $RETVAL -ne 0 ]; then | |
43 | killproc hcid >/dev/null 2>&1 | |
44 | if [ "$UART_CONF" != "no" ]; then | |
45 | killproc hciattach >/dev/null 2>&1 | |
46 | fi | |
967b575d | 47 | fi |
967b575d JB |
48 | fi |
49 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/bluetooth | |
50 | else | |
967b575d | 51 | msg_already_running Bluetooth |
967b575d | 52 | fi |
221d00b8 | 53 | ;; |
967b575d JB |
54 | stop) |
55 | if [ -f /var/lock/subsys/bluetooth ]; then | |
56 | if [ -x /usr/sbin/sdpd ]; then | |
221d00b8 | 57 | msg_stopping "Bluetooth SDP" |
58 | killproc sdpd | |
967b575d | 59 | fi |
967b575d JB |
60 | msg_stopping Bluetooth |
61 | killproc hcid | |
967b575d | 62 | if [ "$UART_CONF" != "no" ]; then |
221d00b8 | 63 | killproc hciattach >/dev/null 2>&1 |
967b575d JB |
64 | fi |
65 | rm -f /var/lock/subsys/bluetooth | |
66 | else | |
967b575d | 67 | msg_not_running Bluetooth |
967b575d JB |
68 | fi |
69 | ;; | |
70 | restart) | |
71 | $0 stop | |
72 | $0 start | |
18c1a831 | 73 | exit $? |
967b575d | 74 | ;; |
18c1a831 | 75 | reload|force-reload) |
967b575d | 76 | if [ -f /var/lock/subsys/bluetooth ]; then |
967b575d JB |
77 | msg_reloading Bluetooth |
78 | killproc hcid -HUP | |
79 | RETVAL=$? | |
80 | else | |
63e20b4e | 81 | msg_not_running Bluetooth >&2 |
82 | exit 7 | |
967b575d JB |
83 | fi |
84 | ;; | |
967b575d JB |
85 | status) |
86 | status hcid | |
63e20b4e | 87 | exit $? |
79f13a51 | 88 | ;; |
967b575d | 89 | *) |
79f13a51 | 90 | msg_usage "$0 {start|stop|restart|reload|force-reload|status}" |
18c1a831 | 91 | exit 3 |
967b575d JB |
92 | esac |
93 | ||
94 | exit $RETVAL | |
95 | ||
96 | # This must be last line ! | |
97 | # vi:syntax=sh:tw=78:ts=8:sw=4 |