Sophie

Sophie

distrib > Mandriva > 2009.1 > x86_64 > by-pkgid > 2cadaa502ea3ef1258708c955dd26c21 > files > 9

bluez-4.33-3.2mdv2009.1.x86_64.rpm

#!/bin/sh
#
# bluetooth:	Start/stop bluetooth services
#
# chkconfig:	2345 25 60
# description:	Bluetooth services for service discovery, authentication, 
#		Human Interface Devices, etc.
#
### BEGIN INIT INFO
# Provides: bluetooth
# Required-Start: messagebus
# Required-Stop: messagebus
# Default-Start: 2 3 4 5
# Short-Description: Start/stop bluetooth services
# Description: Bluetooth services for service discovery, authentication, 
#              Human Interface Devices, etc.
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions


UART_CONF="/etc/bluetooth/uart"

[ -e /etc/sysconfig/bluetooth ] && . /etc/sysconfig/bluetooth

start_uarts()
{
	[ -f $UART_CONF ] || return
	grep -v '^#' $UART_CONF | while read i; do
		/usr/sbin/hciattach $i
	done
}

stop_uarts()
{
	killproc hciattach > /dev/null 2>&1
}

start()
{
	gprintf "Starting Bluetooth services:"
	daemon /sbin/bluetoothd
	[ "$HID2HCI_ENABLE" = "true" ] && hid2hci --tohci > /dev/null 2>&1 || :
	start_uarts
	rfcomm bind all
	touch /var/lock/subsys/bluetooth
	echo ""
}

stop()
{
	gprintf "Stopping Bluetooth services:"
	stop_uarts
	rfcomm release all
	[ "$HID2HCI_UNDO" = "true" ] && hid2hci --tohid > /dev/null 2>&1 || :
	killproc bluetoothd
	grep -q rfcomm /proc/modules && rmmod rfcomm l2cap
	rm -f /var/lock/subsys/bluetooth
	echo ""
}

case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  restart|reload)
        stop
        start
        ;;
  condrestart)
        [ -e /var/lock/subsys/bluetooth ] && (stop; start)
        ;;
  status)
        status bluetoothd
        exit $?
        ;;
  *)
        gprintf "Usage: %s {start|stop|status|restart|reload|condrestart}\n" "$0"
        exit 1
	;;
esac

exit 0