]> git.pld-linux.org Git - packages/bluez-utils.git/blob - bluez-utils.init
- cleaning
[packages/bluez-utils.git] / bluez-utils.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 # See how we were called.
23 case "$1" in
24   start)
25         # Check if the service is already running?
26         if [ ! -f /var/lock/subsys/bluetooth ]; then
27                 # show "Starting %s service" Bluetooth
28                 msg_starting Bluetooth
29                 if [ -f /usr/sbin/hciattach -a "$UART_CONF" != "no" ]; then
30                         grep -v '^#' $UART_CONF | while read i; do
31                                 /usr/sbin/hciattach $i
32                         done
33                 fi
34                 daemon /usr/sbin/hcid -f /etc/bluetooth/hcid.conf
35                 RETVAL=$?
36                 if [ $RETVAL -ne 0 ]; then
37                         killproc hciattach >/dev/null 2>&1
38                 elif [ -x /usr/sbin/sdpd ]; then
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
47                         fi
48                 fi
49                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/bluetooth
50         else
51                 # show "%s service is already running." Bluetooth
52                 msg_already_running Bluetooth
53                 exit 1
54         fi
55         ;;
56   stop)
57         if [ -f /var/lock/subsys/bluetooth ]; then
58                 if [ -x /usr/sbin/sdpd ]; then
59                         msg_stopping "Bluetooth SDP"
60                         killproc sdpd
61                 fi
62                 # show "Stopping %s service" Bluetooth
63                 msg_stopping Bluetooth
64                 killproc hcid
65                 RETVAL=$?
66                 if [ "$UART_CONF" != "no" ]; then
67                         killproc hciattach >/dev/null 2>&1
68                 fi
69                 rm -f /var/lock/subsys/bluetooth
70         else
71                 # show "%s service is not running." Bluetooth
72                 msg_not_running Bluetooth
73                 exit 1
74         fi      
75         ;;
76   restart)
77         $0 stop
78         $0 start
79         ;;
80   reload)
81         if [ -f /var/lock/subsys/bluetooth ]; then
82                 # show "Reload %s service" Bluetooth
83                 msg_reloading Bluetooth
84                 busy
85                 killproc hcid -HUP
86                 RETVAL=$?
87                 [ $RETVAL -eq 0 ] && ok || died
88         else
89                 # show "%s service is not running." Bluetooth
90                 msg_not_running Bluetooth
91                 RETVAL=1
92         fi
93         ;;
94   force-reload)
95         # if program allows reloading without stopping
96         $0 reload
97         ;;
98   status)
99         status hcid
100         RETVAL=$?
101         ;;
102   *)
103         # show "Usage: %s {start|stop|restart|reload|force-reload|status}"
104         msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
105         exit 1
106 esac
107
108 exit $RETVAL
109
110 # This must be last line !
111 # vi:syntax=sh:tw=78:ts=8:sw=4
This page took 0.156538 seconds and 4 git commands to generate.