#!/sbin/runscript
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/perl/Gentoo-Probe/t/sandbox/usr/portage/net-wireless/bluez-utils/files/bluetooth.rc,v 1.1 2004/06/20 09:09:36 linguist Exp $

UART_CONF="/etc/bluetooth/uart"

depend() {
	after hotplug
}

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

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

start() {
	local RETVAL
   	ebegin "Starting Bluetooth"
	[ -x /usr/sbin/hcid ] && \
		start-stop-daemon --start --quiet --exec /usr/sbin/hcid
	RETVAL=$?		
	[ $RETVAL -a -x /usr/sbin/sdpd ] && \
		start-stop-daemon --start --quiet --exec /usr/sbin/sdpd
	RETVAL=$?
	start_uarts
	eend ${RETVAL}
}
	
stop() {
	local RETVAL
	ebegin "Shutting down Bluetooth"
	[ -x /usr/sbin/hcid ] && \
	  start-stop-daemon --stop --quiet --exec /usr/sbin/hcid
	RETVAL=$?
	[ -x /usr/sbin/sdpd ] && \
		start-stop-daemon --stop --quiet --exec /usr/sbin/sdpd
	RETVAL=$?	
	stop_uarts
	eend ${RETVAL}
}
