NetBSD/etc/rc.d/btdevctl

40 lines
730 B
Bash

#!/bin/sh
#
# $NetBSD: btdevctl,v 1.4 2007/07/23 18:06:56 plunky Exp $
#
# PROVIDE: btdevctl
# REQUIRE: bluetooth bthcid
# BEFORE: LOGIN
$_rc_subr_loaded . /etc/rc.subr
name="btdevctl"
rcvar=${name}
required_files="/etc/bluetooth/btdevctl.conf"
start_cmd='do_btdevctl "-A" "Attaching"'
stop_cmd='do_btdevctl "-D" "Detaching"'
do_btdevctl()
{
echo "${2} Bluetooth devices:"
while read -r service address device junk; do
case ${service} in
\#*|"")
continue
;;
esac
if [ -z ${device} -o ${junk} ]; then
echo "${name}: invalid entry"
return 1
fi
/usr/sbin/btdevctl ${1} "-a" ${address} "-d" ${device} "-s" ${service}
done < /etc/bluetooth/btdevctl.conf
}
load_rc_config ${name}
run_rc_command "$1"