]> git.pld-linux.org Git - packages/bluez-utils.git/blobdiff - bluez-utils.init
Typo
[packages/bluez-utils.git] / bluez-utils.init
index 4de86b0ca38ed78250fe4d3a50062589f4e82b28..e4716e387455be028b1701a5ce858dbd36874436 100644 (file)
@@ -19,93 +19,139 @@ if [ "$UART_CONF" != "no" -a ! -f "$UART_CONF" ]; then
        UART_CONF="no"
 fi
 
-# See how we were called.
-case "$1" in
-  start)
+start() {
        # Check if the service is already running?
        if [ ! -f /var/lock/subsys/bluetooth ]; then
-               # show "Starting %s service" Bluetooth
-               msg_starting Bluetooth
+               msg_starting bluetooth; started
+               if is_yes "${HID2HCI_ENABLE}" && [ -x /usr/sbin/hid2hci ]; then
+                       msg_starting hid2hci
+                       daemon /usr/sbin/hid2hci -0 -q    #be quiet
+                       RETVAL=$?
+                       /bin/sleep 1 # delay for hid's to be detected by hotplug
+               fi
+               
+               if is_yes "${HCID_ENABLE}" && [ -x /usr/sbin/hcid ]; then
+                       msg_starting hcid
+                       daemon /usr/sbin/hcid -f /etc/bluetooth/hcid.conf
+                       RETVAL=$?
+               fi
+       
+               if is_yes "${SDPD_ENABLE}" && [ -x /usr/sbin/sdpd ]; then
+                       msg_starting sdpd
+                       daemon /usr/sbin/sdpd
+                       RETVAL=$?
+               fi
+               
+               if is_yes "${HIDD_ENABLE}" && [ -x /usr/bin/hidd ]; then
+                       msg_starting hidd
+                       daemon /usr/bin/hidd ${HIDD_OPTIONS} --server
+                       RETVAL=$?
+               fi
+
+               if is_yes "${RFCOMM_ENABLE}" && [ -x /usr/bin/rfcomm ]; then
+                       msg_starting rfcomm
+                       daemon /usr/bin/rfcomm -f /etc/bluetooth/rfcomm.conf bind all
+                       RETVAL=$?
+               fi
+       
+               if is_yes "${DUND_ENABLE}" && [ -x /usr/bin/dund ]; then
+                       msg_starting dund
+                       daemon /usr/bin/dund ${DUND_OPTIONS}
+                       RETVAL=$?
+               fi
+       
+               if is_yes "${PAND_ENABLE}" && [ -x /usr/bin/pand ]; then
+                       msg_starting pand
+                       daemon /usr/bin/pand ${PAND_OPTIONS}
+                       RETVAL=$?
+               fi
+
                if [ -f /usr/sbin/hciattach -a "$UART_CONF" != "no" ]; then
                        grep -v '^#' $UART_CONF | while read i; do
                                /usr/sbin/hciattach $i
                        done
                fi
-               daemon /usr/sbin/hcid -f /etc/bluetooth/hcid.conf
-               RETVAL=$?
-               if [ $RETVAL -ne 0 ]; then
-                       killproc hciattach >/dev/null 2>&1
-               elif [ -x /usr/sbin/sdpd ]; then
-                       msg_starting "Bluetooth SDP"
-                       daemon /usr/sbin/sdpd
-                       RETVAL=$?
-                       if [ $RETVAL -ne 0 ]; then
-                               killproc hcid >/dev/null 2>&1
-                               if [ "$UART_CONF" != "no" ]; then
-                                       killproc hciattach >/dev/null 2>&1
-                               fi
-                       fi
-               fi
                [ $RETVAL -eq 0 ] && touch /var/lock/subsys/bluetooth
        else
-               # show "%s service is already running." Bluetooth
-               msg_already_running Bluetooth
-               exit 1
+               msg_already_running bluetooth
        fi
-       ;;
-  stop)
+}
+
+stop() {
        if [ -f /var/lock/subsys/bluetooth ]; then
-               if [ -x /usr/sbin/sdpd ]; then
-                       msg_stopping "Bluetooth SDP"
-                       killproc sdpd
+               if is_yes "${PAND_ENABLE}" && [ -x /usr/bin/pand ]; then
+                       msg_stopping pand
+                       killproc /usr/bin/pand
                fi
-               # show "Stopping %s service" Bluetooth
-               msg_stopping Bluetooth
-               killproc hcid
-               RETVAL=$?
+
+               if is_yes "${DUND_ENABLE}" && [ -x /usr/bin/dund ]; then
+                       msg_stopping dund
+                       killproc /usr/bin/dund
+               fi
+
+               if is_yes "${RFCOMM_ENABLE}" && [ -x /usr/bin/rfcomm ]; then
+                       msg_stopping rfcomm
+                       daemon /usr/bin/rfcomm release all
+               fi
+
+               if is_yes "${HIDD_ENABLE}" && [ -x  /usr/bin/hidd ]; then
+                       msg_stopping hidd
+                       killproc /usr/bin/hidd
+               fi
+       
+               if is_yes "${SDPD_ENABLE}" && [ -x /usr/sbin/sdpd ]; then
+                       msg_stopping sdpd
+                       killproc /usr/sbin/sdpd
+               fi
+       
+               if is_yes "${HCID_ENABLE}" && [ -x /usr/sbin/hcid ]; then
+                       msg_stopping hcid
+                       killproc /usr/sbin/hcid
+               fi
+
                if [ "$UART_CONF" != "no" ]; then
                        killproc hciattach >/dev/null 2>&1
                fi
                rm -f /var/lock/subsys/bluetooth
        else
-               # show "%s service is not running." Bluetooth
-               msg_not_running Bluetooth
-               exit 1
-       fi      
+               msg_not_running bluetooth
+       fi
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+       start
+       ;;
+  stop)
+       stop
        ;;
   restart)
-       $0 stop
-       $0 start
+       stop
+       start
        ;;
-  reload)
+  reload|force-reload)
        if [ -f /var/lock/subsys/bluetooth ]; then
-               # show "Reload %s service" Bluetooth
-               msg_reloading Bluetooth
-               busy
+               msg_reloading hcid
                killproc hcid -HUP
                RETVAL=$?
-               [ $RETVAL -eq 0 ] && ok || died
        else
-               # show "%s service is not running." Bluetooth
-               msg_not_running Bluetooth
-               RETVAL=1
+               msg_not_running bluetooth
+               exit 7
        fi
        ;;
-  force-reload)
-       # if program allows reloading without stopping
-       $0 reload
-       ;;
   status)
-       status hcid
-       RETVAL=$?
+       is_yes "${HID2HCI_ENABLE}" && status hid2hci
+       is_yes "${HCID_ENABLE}" && status hcid
+       is_yes "${SDPD_ENABLE}" && status sdpd
+       is_yes "${HIDD_ENABLE}" && status hidd
+       is_yes "${DUND_ENABLE}" && status dund
+       exit $?
        ;;
   *)
-       # show "Usage: %s {start|stop|restart|reload|force-reload|status}"
        msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
-       exit 1
+       exit 3
 esac
 
 exit $RETVAL
-
-# This must be last line !
-# vi:syntax=sh:tw=78:ts=8:sw=4
This page took 0.062975 seconds and 4 git commands to generate.