#!/sbin/runscript

depend()
{
	after coldplug
	need dbus localmount
}

start()
{
	einfo "Starting bluetooth subsystem"
	eindent

	ebegin "Starting bluetoothd"
	start-stop-daemon --start --exec /usr/sbin/bluetoothd \
		$BLUETOOTHD_OPTIONS
	eend $?
	if [ -n "$RFCOMM_START" ]; then
		ebegin "Starting rfcomm"
		/usr/bin/rfcomm -f $RFCOMM_CONF bind all
		eend $?
	fi
	if [ -n "$HIDD_START" ]; then
		ebegin "Starting hidd"
		start-stop-daemon --start --exec /usr/bin/hidd \
			$HIDD_OPTIONS --server
		eend $?
	fi
	if [ -n "$DUND_START" ]; then
		ebegin "Starting dund"
		start-stop-daemon --start --exec /usr/bin/dund \
			$DUND_OPTIONS
		eend $?
	fi
	if [ -n "$PAND_START" ]; then
		ebegin "Starting pand"
		start-stop-daemon --start --exec /usr/bin/pand \
			$PAND_OPTIONS
		eend $?
	fi
	eoutdent
	eend $?
}

stop()
{
	ebegin "Stopping bluetooth subsystem"

	if [ -n "$PAND_START" ]; then
		start-stop-daemon --stop --quiet --exec /usr/bin/pand
		eend $?
	fi
	if [ -n "$DUND_START" ]; then
		start-stop-daemon --stop --quiet --exec /usr/bin/dund
		eend $?
	fi
	if [ -n "$HIDD_START" ]; then
		start-stop-daemon --stop --quiet --exec /usr/bin/hidd
		eend $?
	fi
	start-stop-daemon --stop --quiet --exec /usr/sbin/bluetoothd
	eend $?
}	
