#!/bin/sh
#
# Start/stop the Bluetooth daemons
#

set -e

PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=bluetooth
DESC="Bluetooth subsystem"

DAEMON_NAME=bluetoothd

DAEMON_EXEC="`which $DAEMON_NAME || true`"

DAEMON_ENABLE=true

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

case "$1" in
  start)
	echo -n "Starting $DESC:"
	if $DAEMON_ENABLE && [ -x "$DAEMON_EXEC" ]; then
		$DAEMON_EXEC
		echo -n " $DAEMON_NAME"
	fi
	echo "."
	;;
  stop)
	echo -n "Stopping $DESC:"
	killall $DAEMON_NAME > /dev/null 2>&1 || true
	echo -n " $DAEMON_NAME"
	echo "."
	;;
  restart)
        bluetooth_stop ;
        sleep 1
        bluetooth_start ;
        ;;
  *)
        echo "Usage: $N start|stop|restart" >&2
        exit 1
        ;;

esac

exit 0
