X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=bluez.init;h=6b89ff4c522349a5e4c0fa4b9fa317c7ea8a603a;hb=b8acde542ebea66a31788f7cdb6af789869dcda8;hp=a45ca2d2fbeb71c16a0b578437484abec32f1105;hpb=ebcc455cba21b82af85caa5315dfe5b36650a058;p=packages%2Fbluez.git diff --git a/bluez.init b/bluez.init index a45ca2d..6b89ff4 100644 --- a/bluez.init +++ b/bluez.init @@ -1,8 +1,8 @@ #!/bin/sh # -# bluetooth Bluetooth subsystem starting and stopping +# bluetooth Bluetooth subsystem starting and stopping. Turn HID adapters into Bluetooth ones. # -# chkconfig: 345 25 90 +# chkconfig: 345 50 83 # # description: Bluetooth subsystem # @@ -12,153 +12,78 @@ # Source function library . /etc/rc.d/init.d/functions -UART_CONF="/etc/bluetooth/uart" [ -f /etc/sysconfig/bluetooth ] && . /etc/sysconfig/bluetooth -if [ "$UART_CONF" != "no" -a ! -f "$UART_CONF" ]; then - UART_CONF="no" -fi - start() { # Check if the service is already running? - if [ ! -f /var/lock/subsys/bluetooth ]; then - if is_yes "${DAEMON_ENABLE}" && [ -x /usr/sbin/bluetoothd ]; then - msg_starting bluetooth - daemon /usr/sbin/bluetoothd - RETVAL=$? - fi - - 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 - HCID_FLAGS="-f /etc/bluetooth/hcid.conf" - - if is_yes "${SDPD_ENABLE}" ; then - HCID_FLAGS="$HCID_FLAGS -s" - fi - msg_starting hcid - daemon /usr/sbin/hcid $HCID_FLAGS - 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 - touch /var/lock/subsys/bluetooth - else + if [ -f /var/lock/subsys/bluetooth ]; then msg_already_running bluetooth + return fi + + if [ ! -x /sbin/udevadm ]; then + return + fi + + msg_starting "Bluetooth devices" + daemon /sbin/udevadm trigger --subsystem-match=bluetooth --action=add + RETVAL=$? + touch /var/lock/subsys/bluetooth } stop() { - if [ -f /var/lock/subsys/bluetooth ]; then - if is_yes "${PAND_ENABLE}" && [ -x /usr/bin/pand ]; then - msg_stopping pand - killproc /usr/bin/pand - fi - - if is_yes "${DUND_ENABLE}" && [ -x /usr/bin/dund ]; then - msg_stopping dund - killproc /usr/bin/dund - fi + if [ ! -f /var/lock/subsys/bluetooth ]; then + msg_not_running bluetooth + return + fi - if is_yes "${RFCOMM_ENABLE}" && [ -x /usr/bin/rfcomm ]; then - msg_stopping rfcomm - daemon /usr/bin/rfcomm release all - fi + # nothing needed to stop it + rm -f /var/lock/subsys/bluetooth +} - if is_yes "${HIDD_ENABLE}" && [ -x /usr/bin/hidd ]; then - msg_stopping hidd - killproc /usr/bin/hidd - fi - - if is_yes "${HCID_ENABLE}" && [ -x /usr/sbin/hcid ]; then - msg_stopping hcid - killproc /usr/sbin/hcid - fi +condrestart() { + if [ ! -f /var/lock/subsys/bluetooth ]; then + msg_not_running bluetooth + RETVAL=$1 + return + fi - if is_yes "${DAEMON_ENABLE}" && [ -x /usr/sbin/bluetoothd ]; then - msg_stopping bluetooth - killproc /usr/sbin/bluetoothd - fi + stop + start +} - if [ "$UART_CONF" != "no" ]; then - killproc hciattach >/dev/null 2>&1 - fi - rm -f /var/lock/subsys/bluetooth - else +status() { + if [ ! -f /var/lock/subsys/bluetooth ]; then msg_not_running bluetooth + RETVAL=3 + return $RETVAL fi + + nls "bluetooth is running" } RETVAL=0 # See how we were called. case "$1" in start) - start + start ;; stop) - stop + stop ;; - restart) + restart|reload|force-reload) stop start ;; - reload|force-reload) - if [ -f /var/lock/subsys/bluetooth ]; then - msg_reloading hcid - killproc hcid -HUP - RETVAL=$? - else - msg_not_running bluetooth - exit 7 - fi + try-restart) + condrestart 0 ;; status) - 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 - if [ -f /var/lock/subsys/bluetooth ]; then - exit 0 - else - exit 1 - fi + status + RETVAL=$? ;; *) - msg_usage "$0 {start|stop|restart|reload|force-reload|status}" + msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}" exit 3 esac