Module Name: src
Committed By: plunky
Date: Fri May 27 09:28:43 UTC 2011
Modified Files:
src/distrib/sets/lists/etc: mi
src/etc/defaults: rc.conf
src/etc/mtree: special
src/etc/powerd/scripts: sleep_button
src/etc/rc.d: Makefile btattach btconfig btdevctl bthcid sdpd
src/share/man/man5: rc.conf.5
src/usr.sbin/postinstall: postinstall
Added Files:
src/etc/rc.d: bluetooth
Log Message:
provide a new 'bluetooth' rc.d script, to handle Bluetooth configuration
in a simpler manner. This replaces btattach, btconfig, bthcid, btdevctl
and sdpd scripts, and also should not require any configuration settings
other than "bluetooth=YES", though the full range of configurations is
still possible.
To generate a diff of this commit:
cvs rdiff -u -r1.223 -r1.224 src/distrib/sets/lists/etc/mi
cvs rdiff -u -r1.112 -r1.113 src/etc/defaults/rc.conf
cvs rdiff -u -r1.137 -r1.138 src/etc/mtree/special
cvs rdiff -u -r1.7 -r1.8 src/etc/powerd/scripts/sleep_button
cvs rdiff -u -r1.83 -r1.84 src/etc/rc.d/Makefile
cvs rdiff -u -r0 -r1.1 src/etc/rc.d/bluetooth
cvs rdiff -u -r1.1 -r1.2 src/etc/rc.d/btattach src/etc/rc.d/btconfig
cvs rdiff -u -r1.4 -r1.5 src/etc/rc.d/btdevctl
cvs rdiff -u -r1.2 -r1.3 src/etc/rc.d/bthcid
cvs rdiff -u -r1.3 -r1.4 src/etc/rc.d/sdpd
cvs rdiff -u -r1.146 -r1.147 src/share/man/man5/rc.conf.5
cvs rdiff -u -r1.117 -r1.118 src/usr.sbin/postinstall/postinstall
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/distrib/sets/lists/etc/mi
diff -u src/distrib/sets/lists/etc/mi:1.223 src/distrib/sets/lists/etc/mi:1.224
--- src/distrib/sets/lists/etc/mi:1.223 Mon Apr 11 22:09:56 2011
+++ src/distrib/sets/lists/etc/mi Fri May 27 09:28:41 2011
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.223 2011/04/11 22:09:56 martin Exp $
+# $NetBSD: mi,v 1.224 2011/05/27 09:28:41 plunky Exp $
#
# Note: end-user configuration files that are moved to another location
# should not be marked "obsolete"; they should just be removed from
@@ -170,13 +170,14 @@
./etc/rc.d/altqd etc-router-rc
./etc/rc.d/amd etc-amd-rc
./etc/rc.d/apmd etc-sys-rc
+./etc/rc.d/bluetooth etc-sys-rc
./etc/rc.d/bootconf.sh etc-sys-rc
./etc/rc.d/bootparams etc-bootserver-rc
-./etc/rc.d/btattach etc-sys-rc
-./etc/rc.d/btconfig etc-sys-rc
+./etc/rc.d/btattach etc-obsolete obsolete
+./etc/rc.d/btconfig etc-obsolete obsolete
./etc/rc.d/btcontrol etc-obsolete obsolete
-./etc/rc.d/btdevctl etc-sys-rc
-./etc/rc.d/bthcid etc-sys-rc
+./etc/rc.d/btdevctl etc-obsolete obsolete
+./etc/rc.d/bthcid etc-obsolete obsolete
./etc/rc.d/btuartd etc-obsolete obsolete
./etc/rc.d/ccd etc-sys-rc
./etc/rc.d/cgd etc-sys-rc
@@ -265,7 +266,7 @@
./etc/rc.d/rwho etc-net-rc
./etc/rc.d/savecore etc-sys-rc
./etc/rc.d/screenblank etc-sys-rc
-./etc/rc.d/sdpd etc-sys-rc
+./etc/rc.d/sdpd etc-obsolete obsolete
./etc/rc.d/securelevel etc-sys-rc
./etc/rc.d/sshd etc-secsh-rc
./etc/rc.d/staticroute etc-sys-rc
Index: src/etc/defaults/rc.conf
diff -u src/etc/defaults/rc.conf:1.112 src/etc/defaults/rc.conf:1.113
--- src/etc/defaults/rc.conf:1.112 Fri Feb 18 00:42:20 2011
+++ src/etc/defaults/rc.conf Fri May 27 09:28:42 2011
@@ -1,4 +1,4 @@
-# $NetBSD: rc.conf,v 1.112 2011/02/18 00:42:20 jmcneill Exp $
+# $NetBSD: rc.conf,v 1.113 2011/05/27 09:28:42 plunky Exp $
#
# /etc/defaults/rc.conf --
# default configuration of /etc/rc.conf
@@ -306,12 +306,12 @@
# ISDN daemon
isdnd=NO isdnd_flags=""
-# Bluetooth daemons
-btattach=NO # Bluetooth attach serial HCI
-btconfig=NO # Bluetooth controller configuration
-btdevctl=NO # Bluetooth device configuration
-bthcid=NO bthcid_flags="" # Bluetooth HCI daemon
-sdpd=NO sdpd_flags="" # Service Discovery daemon
+# Bluetooth configuration
+bluetooth=NO
+# and the following are used when bluetooth=YES
+btconfig_devices="" # all
+bthcid=YES bthcid_flags=""
+sdpd=YES sdpd_flags=""
# Other daemons.
#
Index: src/etc/mtree/special
diff -u src/etc/mtree/special:1.137 src/etc/mtree/special:1.138
--- src/etc/mtree/special:1.137 Sun Apr 17 13:07:18 2011
+++ src/etc/mtree/special Fri May 27 09:28:42 2011
@@ -1,4 +1,4 @@
-# $NetBSD: special,v 1.137 2011/04/17 13:07:18 martin Exp $
+# $NetBSD: special,v 1.138 2011/05/27 09:28:42 plunky Exp $
# @(#)special 8.2 (Berkeley) 1/23/94
#
# This file may be overwritten on upgrades.
@@ -186,12 +186,9 @@
./etc/rc.d/altqd type=file mode=0555
./etc/rc.d/amd type=file mode=0555
./etc/rc.d/apmd type=file mode=0555
+./etc/rc.d/bluetooth type=file mode=0555
./etc/rc.d/bootconf.sh type=file mode=0555
./etc/rc.d/bootparams type=file mode=0555
-./etc/rc.d/btattach type=file mode=0555
-./etc/rc.d/btconfig type=file mode=0555
-./etc/rc.d/btdevctl type=file mode=0555
-./etc/rc.d/bthcid type=file mode=0555
./etc/rc.d/ccd type=file mode=0555
./etc/rc.d/cgd type=file mode=0555
./etc/rc.d/cleartmp type=file mode=0555
@@ -268,7 +265,6 @@
./etc/rc.d/rwho type=file mode=0555
./etc/rc.d/savecore type=file mode=0555
./etc/rc.d/screenblank type=file mode=0555
-./etc/rc.d/sdpd type=file mode=0555
./etc/rc.d/securelevel type=file mode=0555
./etc/rc.d/sshd type=file mode=0555
./etc/rc.d/staticroute type=file mode=0555
Index: src/etc/powerd/scripts/sleep_button
diff -u src/etc/powerd/scripts/sleep_button:1.7 src/etc/powerd/scripts/sleep_button:1.8
--- src/etc/powerd/scripts/sleep_button:1.7 Fri Dec 31 09:36:15 2010
+++ src/etc/powerd/scripts/sleep_button Fri May 27 09:28:42 2011
@@ -1,6 +1,6 @@
#!/bin/sh -
#
-# $NetBSD: sleep_button,v 1.7 2010/12/31 09:36:15 jruoho Exp $
+# $NetBSD: sleep_button,v 1.8 2011/05/27 09:28:42 plunky Exp $
#
# Generic script for sleep button events.
#
@@ -11,8 +11,7 @@
case "${2}" in
pressed)
- /etc/rc.d/btdevctl stop
- /etc/rc.d/btconfig stop
+ /etc/rc.d/bluetooth stop
/etc/rc.d/ntpd stop
/etc/rc.d/dhclient stop
/etc/rc.d/network stop
@@ -36,8 +35,7 @@
/etc/rc.d/dhclient start
/etc/rc.d/ntpdate start
/etc/rc.d/ntpd start
- /etc/rc.d/btconfig start
- /etc/rc.d/btdevctl start
+ /etc/rc.d/bluetooth start
;;
released)
Index: src/etc/rc.d/Makefile
diff -u src/etc/rc.d/Makefile:1.83 src/etc/rc.d/Makefile:1.84
--- src/etc/rc.d/Makefile:1.83 Fri Feb 18 00:42:20 2011
+++ src/etc/rc.d/Makefile Fri May 27 09:28:42 2011
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.83 2011/02/18 00:42:20 jmcneill Exp $
+# $NetBSD: Makefile,v 1.84 2011/05/27 09:28:42 plunky Exp $
.include <bsd.own.mk>
@@ -16,7 +16,7 @@
CONFIGFILES=\
DAEMON DISKS LOGIN NETWORKING SERVERS \
accounting altqd amd apmd \
- bootconf.sh bootparams btattach btconfig btdevctl bthcid \
+ bluetooth bootconf.sh bootparams \
ccd cgd cleartmp cron \
dhclient dhcpcd dhcpd dhcrelay dmesg downinterfaces envsys \
fsck fsck_root ftp_proxy ftpd \
@@ -33,7 +33,7 @@
quota \
racoon rpcbind raidframe raidframeparity rarpd rbootd rndctl \
root route6d routed rtadvd rtclocaltime rtsold rwho \
- savecore screenblank sdpd securelevel sshd \
+ savecore screenblank securelevel sshd \
staticroute swap1 swap2 sysctl sysdb syslogd \
timed tpctl ttys \
veriexec virecover wdogctl wpa_supplicant wscons wsmoused \
Index: src/etc/rc.d/btattach
diff -u src/etc/rc.d/btattach:1.1 src/etc/rc.d/btattach:1.2
--- src/etc/rc.d/btattach:1.1 Tue Apr 15 11:17:47 2008
+++ src/etc/rc.d/btattach Fri May 27 09:28:42 2011
@@ -1,44 +0,0 @@
-#!/bin/sh
-#
-# $NetBSD: btattach,v 1.1 2008/04/15 11:17:47 plunky Exp $
-#
-
-# PROVIDE: btattach
-# REQUIRE: DAEMON
-# BEFORE: bluetooth
-
-$_rc_subr_loaded . /etc/rc.subr
-
-name="btattach"
-rcvar=${name}
-required_files="/etc/bluetooth/btattach.conf"
-start_cmd="btattach_start"
-stop_cmd="btattach_stop"
-
-btattach_start()
-{
-
- while read type tty speed flags; do
- case ${type} in
- \#*|"")
- continue
- ;;
- esac
-
- /usr/sbin/btattach ${flags} ${type} ${tty} ${speed}
- done < /etc/bluetooth/btattach.conf
-}
-
-btattach_stop()
-{
-
- pids="$(check_process btattach)"
- if [ -n "${pids}" ]; then
- for pid in ${pids}; do
- kill $sig_stop $pid
- done
- fi
-}
-
-load_rc_config ${name}
-run_rc_command "$1"
Index: src/etc/rc.d/btconfig
diff -u src/etc/rc.d/btconfig:1.1 src/etc/rc.d/btconfig:1.2
--- src/etc/rc.d/btconfig:1.1 Mon Jun 19 15:44:36 2006
+++ src/etc/rc.d/btconfig Fri May 27 09:28:42 2011
@@ -1,67 +0,0 @@
-#!/bin/sh
-#
-# $NetBSD: btconfig,v 1.1 2006/06/19 15:44:36 gdamore Exp $
-#
-
-# PROVIDE: bluetooth
-# REQUIRE: DAEMON
-# BEFORE: LOGIN
-
-$_rc_subr_loaded . /etc/rc.subr
-
-name="btconfig"
-rcvar=${name}
-command="/usr/sbin/${name}"
-start_cmd="btconfig_start"
-stop_cmd="btconfig_stop"
-status_cmd="btconfig_status"
-
-btconfig_start()
-{
- echo -n 'Configuring Bluetooth controllers:'
-
- #
- # Configure Bluetooth controllers.
- #
- # If ${btconfig_devices} is set, it should be a list of devices to
- # configure. Otherwise, all available devices will be configured.
- #
- # If ${btconfig_<dev>} is set, it will be used as the parameter
- # list for btconfig. Otherwise ${btconfig_args} will be used or
- # if that is not set, the default string "enable" will be used.
- #
-
- devs="${btconfig_devices:-$(${command} -l)}"
- for dev in ${devs}; do
- eval args="\$btconfig_${dev}"
- if [ -z "${args}" ]; then
- args="${btconfig_args:-enable}"
- fi
-
- echo -n " ${dev}"
- ${command} ${dev} ${args}
- done
-
- echo '.'
-}
-
-btconfig_stop()
-{
- echo -n 'Disabling Bluetooth controllers:'
-
- devs="${btconfig_devices:-$(${command} -l)}"
- for dev in ${devs}; do
- echo -n " ${dev}"
- ${command} ${dev} disable
- done
-
- echo '.'
-}
-
-btconfig_status()
-{
- ${command}
-}
-
-load_rc_config ${name}
-run_rc_command "$1"
Index: src/etc/rc.d/btdevctl
diff -u src/etc/rc.d/btdevctl:1.4 src/etc/rc.d/btdevctl:1.5
--- src/etc/rc.d/btdevctl:1.4 Mon Jul 23 18:06:56 2007
+++ src/etc/rc.d/btdevctl Fri May 27 09:28:42 2011
@@ -1,39 +0,0 @@
-#!/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"
Index: src/etc/rc.d/bthcid
diff -u src/etc/rc.d/bthcid:1.2 src/etc/rc.d/bthcid:1.3
--- src/etc/rc.d/bthcid:1.2 Tue Jun 1 21:08:13 2010
+++ src/etc/rc.d/bthcid Fri May 27 09:28:42 2011
@@ -1,19 +0,0 @@
-#!/bin/sh
-#
-# $NetBSD: bthcid,v 1.2 2010/06/01 21:08:13 wiz Exp $
-#
-
-# PROVIDE: bthcid
-# REQUIRE: bluetooth
-# BEFORE: LOGIN
-
-$_rc_subr_loaded . /etc/rc.subr
-
-name="bthcid"
-rcvar=$name
-
-command="/usr/sbin/${name}"
-pidfile="/var/run/${name}.pid"
-
-load_rc_config $name
-run_rc_command "$1"
Index: src/etc/rc.d/sdpd
diff -u src/etc/rc.d/sdpd:1.3 src/etc/rc.d/sdpd:1.4
--- src/etc/rc.d/sdpd:1.3 Tue Jun 1 21:08:13 2010
+++ src/etc/rc.d/sdpd Fri May 27 09:28:42 2011
@@ -1,17 +0,0 @@
-#!/bin/sh
-#
-# $NetBSD: sdpd,v 1.3 2010/06/01 21:08:13 wiz Exp $
-#
-
-# PROVIDE: sdpd
-# REQUIRE: bluetooth
-# BEFORE: LOGIN
-
-$_rc_subr_loaded . /etc/rc.subr
-
-name="sdpd"
-rcvar=$name
-command="/usr/sbin/${name}"
-
-load_rc_config $name
-run_rc_command "$1"
Index: src/share/man/man5/rc.conf.5
diff -u src/share/man/man5/rc.conf.5:1.146 src/share/man/man5/rc.conf.5:1.147
--- src/share/man/man5/rc.conf.5:1.146 Fri Mar 18 16:21:46 2011
+++ src/share/man/man5/rc.conf.5 Fri May 27 09:28:42 2011
@@ -1,4 +1,4 @@
-.\" $NetBSD: rc.conf.5,v 1.146 2011/03/18 16:21:46 jruoho Exp $
+.\" $NetBSD: rc.conf.5,v 1.147 2011/05/27 09:28:42 plunky Exp $
.\"
.\" Copyright (c) 1996 Matthew R. Green
.\" All rights reserved.
@@ -1322,50 +1322,50 @@
Passes
.Sy statd_flags .
.El
-.Ss Bluetooth configuration and daemons
+.Ss Bluetooth support
.Bl -tag -width net_interfaces
-.It Sy btattach
+.It Sy bluetooth
Boolean value.
-Attach serial bluetooth interfaces as listed in the configuration file
-.Pa /etc/bluetooth/btdevctl.conf .
-.It Sy btconfig
-Boolean value.
-Configure bluetooth devices.
-If the
-.Sy btconfig_devices
-variable below is not specified, all devices known to the system
-will be configured.
-For each device, configuration arguments are first looked for
-in the
-.Sy btconfig_{dev}
-variable, otherwise the value of the
-.Sy btconfig_args
-variable will be used, and if that is not specified the default string is
-.Sq enable .
+Configure Bluetooth support, comprising the following tasks:
+.Bl -dash -compact
+.It
+attach serial Bluetooth controllers as listed in the
+.Pa /etc/bluetooth/btdevctl.conf
+configuration file.
+.It
+enable Bluetooth controllers with useful defaults, plus
+additional options as detailed below.
+.It
+optionally, start
+.Xr bthcid 8 ,
+the Bluetooth Link Key/PIN Code manager, passing
+.Sy bthcid_flags .
+.It
+configure local Bluetooth drivers as listed in the
+.Pa /etc/bluetooth/btdevctl.conf
+configuration file.
+.It
+optionally, start
+.Xr sdpd 8 ,
+the Service Discovery server, passing
+.Sy sdpd_flags .
+.El
.It Sy btconfig_devices
-An optional space separated list of bluetooth devices to be configured at
-boot time.
+A string.
+An optional list of Bluetooth controllers to configure.
+.It Sy btconfig_{dev}
+A string.
+Additional configuration options for specific Bluetooth controllers.
.It Sy btconfig_args
-An optional string, containing default arguments for bluetooth devices to
-be configured.
-.It Sy btdevctl
-Boolean value.
-Configure Bluetooth devices as listed in the configuration file
-.Pa /etc/bluetooth/btdevctl.conf .
+A string.
+Additional configuration options for Bluetooth controllers without
+specific options as above.
.It Sy bthcid
Boolean value.
-Runs
-.Xr bthcid 8 ,
-the Bluetooth HCI daemon, which manages link keys and PIN codes for
-Bluetooth links.
-Passes
-.Sy bthcid_flags .
+If set to false, disable starting the Bluetooth Link Key/PIN Code manager.
.It Sy sdpd
Boolean value.
-Runs the Service Discovery Profile daemon,
-.Xr sdpd 8 .
-Passes
-.Sy sdpd_flags .
+If set to false, disable starting the Bluetooth Service Discovery server.
.El
.Ss Other daemons
.Bl -tag -width net_interfaces
Index: src/usr.sbin/postinstall/postinstall
diff -u src/usr.sbin/postinstall/postinstall:1.117 src/usr.sbin/postinstall/postinstall:1.118
--- src/usr.sbin/postinstall/postinstall:1.117 Sun Apr 17 13:16:59 2011
+++ src/usr.sbin/postinstall/postinstall Fri May 27 09:28:42 2011
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: postinstall,v 1.117 2011/04/17 13:16:59 martin Exp $
+# $NetBSD: postinstall,v 1.118 2011/05/27 09:28:42 plunky Exp $
#
# Copyright (c) 2002-2008 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -651,9 +651,10 @@
#
#
-# bluetooth
+# Bluetooth
#
-additem bluetooth "bluetooth configuration is up to date"
+
+additem bluetooth "Bluetooth configuration is up to date"
do_bluetooth()
{
[ -n "$1" ] || err 3 "USAGE: do_bluetooth fix|check"
@@ -669,6 +670,18 @@
"${DEST_DIR}/var/db/btdevctl.plist"
failed=$(( ${failed} + $? ))
+ notfixed=""
+ if [ "${op}" = "fix" ]; then
+ notfixed="${NOT_FIXED}"
+ fi
+ for _v in btattach btconfig btdevctl; do
+ if rcconf_is_set "${op}" "${_v}" "${_v}"; then
+ msg \
+ "${_v} is obsolete in rc.conf(5)${notfixed}: use bluetooth=YES"
+ failed=$(( ${failed} + 1 ))
+ fi
+ done
+
return ${failed}
}
@@ -1070,7 +1083,7 @@
compare_dir "${op}" "${SRC_DIR}/etc/rc.d" "${DEST_DIR}/etc/rc.d" 555 \
DAEMON DISKS LOGIN NETWORKING SERVERS \
accounting altqd amd apmd \
- bootconf.sh bootparams btattach btconfig btdevctl bthcid \
+ bluetooth bootconf.sh bootparams \
ccd cgd cleartmp cron \
dhclient dhcpcd dhcpd dhcrelay dmesg downinterfaces envsys \
fsck fsck_root ftp_proxy ftpd \
@@ -1088,7 +1101,7 @@
quota \
racoon rpcbind raidframe raidframeparity rarpd rbootd rndctl \
root route6d routed rtadvd rtclocaltime rtsold rwho \
- savecore screenblank sdpd securelevel sshd \
+ savecore screenblank securelevel sshd \
staticroute swap1 swap2 sysctl sysdb syslogd \
timed tpctl ttys \
veriexec virecover wdogctl wpa_supplicant wscons wsmoused \
@@ -1111,7 +1124,8 @@
fi
# check for obsolete rc.d files
- for f in NETWORK btcontrol btuartd fsck.sh kerberos nfsiod servers \
+ for f in NETWORK btattach btconfig btcontrol btdevctl bthcid btuartd \
+ fsck.sh kerberos nfsiod sdpd servers \
systemfs daemon gated login poffd portmap sunndd xntpd; do
fd="/etc/rc.d/${f}"
[ -e "${DEST_DIR}${fd}" ] && echo "${fd}"
Added files:
Index: src/etc/rc.d/bluetooth
diff -u /dev/null src/etc/rc.d/bluetooth:1.1
--- /dev/null Fri May 27 09:28:43 2011
+++ src/etc/rc.d/bluetooth Fri May 27 09:28:42 2011
@@ -0,0 +1,134 @@
+#!/bin/sh
+#
+# $NetBSD: bluetooth,v 1.1 2011/05/27 09:28:42 plunky Exp $
+#
+
+# PROVIDE: bluetooth
+# REQUIRE: DAEMON
+# BEFORE: LOGIN
+
+$_rc_subr_loaded . /etc/rc.subr
+
+name="bluetooth"
+rcvar=${name}
+start_cmd="bluetooth_start"
+stop_cmd="bluetooth_stop"
+
+btattach_cmd="/usr/sbin/btattach"
+btconfig_cmd="/usr/sbin/btconfig"
+bthcid_cmd="/usr/sbin/bthcid"
+btdevctl_cmd="/usr/sbin/btdevctl"
+sdpd_cmd="/usr/sbin/sdpd"
+
+btattach_conf="/etc/bluetooth/btattach.conf"
+btdevctl_conf="/etc/bluetooth/btdevctl.conf"
+
+required_files="${btattach_conf} ${btdevctl_conf}"
+
+bluetooth_start()
+{
+ #
+ # attach Bluetooth serial controllers
+ #
+ while read type tty speed flags; do
+ case ${type} in
+ \#*|"")
+ continue
+ ;;
+ esac
+
+ echo "attaching Bluetooth controller to $(basename ${tty})"
+ ${btattach_cmd} ${flags} ${type} ${tty} ${speed}
+ done < ${btattach_conf}
+
+ #
+ # enable Bluetooth controllers.
+ #
+ # If ${btconfig_devices} is set, it is treated as a list of devices
+ # to configure. Otherwise, all available devices will be configured
+ #
+ # For each device we are configuring, enable it with maximum security
+ # settings (not discoverable, not connectable, auth and encryption
+ # required for all connections), relaxed link policy settings and
+ # the link master role, set a class of device for Computer, then apply
+ # any options from the 'btconfig_<dev>' or 'btconfig_args' variables
+ # on top of settings relaxing the security requirements, so that these
+ # can be overridden (btconfig parses all command line options before
+ # acting)
+ #
+ echo -n "configuring Bluetooth controllers:"
+ for dev in ${btconfig_devices:-$(${btconfig_cmd} -l)}; do
+ echo -n " ${dev}"
+ eval args=\${btconfig_${dev}:-\${btconfig_args}}
+ ${btconfig_cmd} ${dev} enable -iscan -pscan auth encrypt
+ ${btconfig_cmd} ${dev} switch hold sniff park master
+ ${btconfig_cmd} ${dev} class 0x000100
+ ${btconfig_cmd} ${dev} iscan pscan -auth -encrypt ${args}
+ done
+ echo "."
+
+ #
+ # start Bluetooth Link Key/PIN Code manager
+ #
+ if checkyesno bthcid; then
+ echo "starting Bluetooth Link Key/PIN Code manager"
+ ${bthcid_cmd} ${bthcid_flags}
+ fi
+
+ #
+ # attach local Bluetooth service drivers
+ #
+ while read -r service addr dev junk; do
+ case ${service} in
+ \#*|"")
+ continue
+ ;;
+ esac
+
+ if [ -z ${dev} -o ${junk} ]; then
+ echo "${name}: invalid entry"
+ return 1
+ fi
+
+ echo "attaching Bluetooth ${service} service from \"${addr}\""
+ ${btdevctl_cmd} -A -a ${addr} -d ${dev} -s ${service}
+ done < ${btdevctl_conf}
+
+ #
+ # start Bluetooth Service Discovery server
+ #
+ if checkyesno sdpd; then
+ echo "starting Bluetooth Service Discovery server"
+ ${sdpd_cmd} ${sdpd_flags}
+ fi
+}
+
+bluetooth_stop()
+{
+ #
+ # disable Bluetooth controllers, detaching local service drivers
+ #
+ echo -n "disabling Bluetooth controllers:"
+ for dev in ${btconfig_devices:-$(${btconfig_cmd} -l)}; do
+ echo -n " ${dev}"
+ ${btconfig_cmd} ${dev} disable
+ done
+ echo "."
+
+ #
+ # halt Service Discovery server, Link Key/PIN Code manager,
+ # and detach Bluetooth serial controllers
+ #
+ p1=$(check_pidfile /var/run/bthcid.pid ${bthcid_cmd})
+ p2=$(check_process ${sdpd_cmd})
+ p3=$(check_process ${btattach_cmd})
+ if [ -n "${p1}${p2}${p3}" ]; then
+ for pid in ${p1} ${p2} ${p3}; do
+ kill ${sig_stop} ${pid}
+ done
+ wait_for_pids ${p1} ${p2} ${p3}
+ fi
+}
+
+load_rc_config ${name}
+run_rc_command "$1"