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