Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src provide a new 'bluetooth' rc.d script, to handle Bluetooth c...
details: https://anonhg.NetBSD.org/src/rev/0d2b7c22eaff
branches: trunk
changeset: 765441:0d2b7c22eaff
user: plunky <plunky%NetBSD.org@localhost>
date: Fri May 27 09:28:41 2011 +0000
description:
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.
diffstat:
distrib/sets/lists/etc/mi | 13 ++-
etc/defaults/rc.conf | 14 ++--
etc/mtree/special | 8 +-
etc/powerd/scripts/sleep_button | 8 +-
etc/rc.d/Makefile | 6 +-
etc/rc.d/bluetooth | 134 +++++++++++++++++++++++++++++++++++++++
etc/rc.d/btattach | 44 ------------
etc/rc.d/btconfig | 67 -------------------
etc/rc.d/btdevctl | 39 -----------
etc/rc.d/bthcid | 19 -----
etc/rc.d/sdpd | 17 ----
share/man/man5/rc.conf.5 | 74 ++++++++++----------
usr.sbin/postinstall/postinstall | 26 +++++-
13 files changed, 213 insertions(+), 256 deletions(-)
diffs (truncated from 665 to 300 lines):
diff -r b9af58cb7e7f -r 0d2b7c22eaff distrib/sets/lists/etc/mi
--- a/distrib/sets/lists/etc/mi Fri May 27 06:51:13 2011 +0000
+++ b/distrib/sets/lists/etc/mi Fri May 27 09:28:41 2011 +0000
@@ -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
diff -r b9af58cb7e7f -r 0d2b7c22eaff etc/defaults/rc.conf
--- a/etc/defaults/rc.conf Fri May 27 06:51:13 2011 +0000
+++ b/etc/defaults/rc.conf Fri May 27 09:28:41 2011 +0000
@@ -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.
#
diff -r b9af58cb7e7f -r 0d2b7c22eaff etc/mtree/special
--- a/etc/mtree/special Fri May 27 06:51:13 2011 +0000
+++ b/etc/mtree/special Fri May 27 09:28:41 2011 +0000
@@ -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
diff -r b9af58cb7e7f -r 0d2b7c22eaff etc/powerd/scripts/sleep_button
--- a/etc/powerd/scripts/sleep_button Fri May 27 06:51:13 2011 +0000
+++ b/etc/powerd/scripts/sleep_button Fri May 27 09:28:41 2011 +0000
@@ -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)
diff -r b9af58cb7e7f -r 0d2b7c22eaff etc/rc.d/Makefile
--- a/etc/rc.d/Makefile Fri May 27 06:51:13 2011 +0000
+++ b/etc/rc.d/Makefile Fri May 27 09:28:41 2011 +0000
@@ -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 \
diff -r b9af58cb7e7f -r 0d2b7c22eaff etc/rc.d/bluetooth
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/rc.d/bluetooth Fri May 27 09:28:41 2011 +0000
@@ -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"
diff -r b9af58cb7e7f -r 0d2b7c22eaff etc/rc.d/btattach
--- a/etc/rc.d/btattach Fri May 27 06:51:13 2011 +0000
+++ b/etc/rc.d/btattach Fri May 27 09:28:41 2011 +0000
@@ -1,44 +0,0 @@
-#!/bin/sh
-#
-# $NetBSD: btattach,v 1.1 2008/04/15 11:17:47 plunky Exp $
-#
Home |
Main Index |
Thread Index |
Old Index