rpms/bluez/devel 97-bluetooth-ondemand.rules, NONE, 1.1 bluetooth.conf, 1.1, 1.2 bluetooth.init, 1.2, 1.3 bluez.spec, 1.63, 1.64

Petr Lautrbach plautrba at fedoraproject.org
Wed May 6 11:25:22 UTC 2009


Author: plautrba

Update of /cvs/pkgs/rpms/bluez/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv10511

Modified Files:
	bluetooth.conf bluetooth.init bluez.spec 
Added Files:
	97-bluetooth-ondemand.rules 
Log Message:
* Tue May 05 2009 Petr Lautrbach <plautrba at redhat.com> 4.38-3
- Start/stop the bluetooth service via udev (#484345)




--- NEW FILE 97-bluetooth-ondemand.rules ---
#bluetooth on demand rules
SUBSYSTEM=="bluetooth", ACTION=="add", RUN+="/sbin/service bluetooth condstart"
SUBSYSTEM=="bluetooth", ACTION=="remove", RUN+="/sbin/service bluetooth condstop"


Index: bluetooth.conf
===================================================================
RCS file: /cvs/pkgs/rpms/bluez/devel/bluetooth.conf,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- bluetooth.conf	11 Sep 2008 02:10:23 -0000	1.1
+++ bluetooth.conf	6 May 2009 11:24:51 -0000	1.2
@@ -4,3 +4,7 @@
 
 # Enable this to switch capable devices back to HID mode on Bluetooth shutdown
 #HID2HCI_UNDO=true
+#
+#Enable this to allow automatic start or stop when bluetooth
+#inserted or removed
+#BLUETOOTH_ONDEMAND=true


Index: bluetooth.init
===================================================================
RCS file: /cvs/pkgs/rpms/bluez/devel/bluetooth.init,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -p -r1.2 -r1.3
--- bluetooth.init	12 Sep 2008 09:34:05 -0000	1.2
+++ bluetooth.init	6 May 2009 11:24:51 -0000	1.3
@@ -16,8 +16,49 @@
 
 [ -e /etc/sysconfig/bluetooth ] && . /etc/sysconfig/bluetooth
 
+is_enabled_in_runlevel() 
+{
+	level=`runlevel | awk '{print $2;}'`
+
+	#check file in runlevel
+	[ -f /etc/rc$level.d/S??bluetooth ] 
+	return $?
+}
+
+has_bt_devices()
+{
+	#Look for Bluetooth adapters:
+	udevadm info --export-db | grep -q -e '/devices/.*/bluetooth/.*'
+
+	return $?
+}
+
+check_condstart()
+{
+	is_enabled_in_runlevel || return $?
+
+	/sbin/service bluetooth status && return 1
+
+	#Look for Bluetooth adapters:
+	has_bt_devices && return 0
+	return 1
+}
+
+condstart()
+{
+	if [ "$BLUETOOTH_ONDEMAND" = "true" ]; then
+		start
+		return $?
+	fi
+	return 1
+}
+
 start()
 {
+	if [ "$BLUETOOTH_ONDEMAND" = "true" ]; then
+		check_condstart || return 1
+	fi
+
 	echo -n $"Starting Bluetooth services:"
 	daemon /usr/sbin/bluetoothd
 	RETVAL=$?
@@ -40,27 +81,57 @@ stop()
 	return $RETVAL
 }
 
+check_condstop()
+{
+	is_enabled_in_runlevel || return $?
+
+	/sbin/service bluetooth status || return $?
+
+	#Look for Bluetooth adapters:
+	has_bt_devices && return 1
+	return 0
+}
+
+condstop()
+{
+	if [ "$BLUETOOTH_ONDEMAND" = "true" ]; then
+		check_condstop || return 1
+	else
+		return 2
+	fi
+
+	stop
+	return $?
+}
+
+
 case "$1" in
   start)
 	start
 	;;
+  condstart)
+	condstart
+	;;
   stop)
 	stop
 	;;
+  condstop)
+	condstop
+	;;
   force-reload|restart|reload)
-        stop
-        start
-        ;;
+	stop
+	start
+	;;
   try-restart|condrestart)
-        [ -e /var/lock/subsys/bluetooth ] && (stop; start)
-        ;;
+	[ -e /var/lock/subsys/bluetooth ] && (stop; start)
+	;;
   status)
-        status bluetoothd
+	status bluetoothd
 	RETVAL=$?
-        ;;
+	;;
   *)
-        echo $"Usage: $0 {start|stop|status|restart|reload|condrestart}"
-        exit 3
+	echo $"Usage: $0 {start|stop|status|restart|reload|condrestart|condstart|condstop}"
+	exit 3
 	;;
 esac
 


Index: bluez.spec
===================================================================
RCS file: /cvs/pkgs/rpms/bluez/devel/bluez.spec,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -p -r1.63 -r1.64
--- bluez.spec	5 May 2009 13:53:20 -0000	1.63
+++ bluez.spec	6 May 2009 11:24:51 -0000	1.64
@@ -1,7 +1,7 @@
 Summary: Bluetooth utilities
 Name: bluez
 Version: 4.38
-Release: 2%{?dist}
+Release: 3%{?dist}
 License: GPLv2+
 Group: Applications/System
 Source: http://www.kernel.org/pub/linux/bluetooth/%{name}-%{version}.tar.gz
@@ -13,6 +13,7 @@ Source5: pand.init
 Source6: pand.conf
 Source7: rfcomm.init
 Source8: bluez-uinput.modules
+Source9: 97-bluetooth-ondemand.rules
 Patch1: bluez-utils-oui-usage.patch
 # https://bugzilla.redhat.com/show_bug.cgi?id=450081
 # http://thread.gmane.org/gmane.linux.bluez.kernel/1687
@@ -36,6 +37,7 @@ Requires: initscripts, bluez-libs = %{ve
 Requires: dbus >= 0.60
 Requires: hwdata >= 0.215
 Requires: dbus-bluez-pin-helper
+Requires: udev >= 130
 Requires(preun): /sbin/chkconfig, /sbin/service
 Requires(post): /sbin/chkconfig, /sbin/service
 
@@ -148,6 +150,7 @@ if test -d ${RPM_BUILD_ROOT}/usr/lib64/c
 fi
 
 install -D -m0644 scripts/bluetooth.rules ${RPM_BUILD_ROOT}/%{_sysconfdir}/udev/rules.d/97-bluetooth-serial.rules
+install -D -m0644 %{SOURCE9} ${RPM_BUILD_ROOT}/%{_sysconfdir}/udev/rules.d/97-bluetooth-ondemand.rules
 install -D -m0755 scripts/bluetooth_serial ${RPM_BUILD_ROOT}/lib/udev/bluetooth_serial
 
 install -D -m0755 %{SOURCE8} $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/modules/bluez-uinput.modules
@@ -214,6 +217,7 @@ fi
 %{_libdir}/bluetooth/
 /lib/udev/bluetooth_serial
 %{_sysconfdir}/udev/rules.d/97-bluetooth-serial.rules
+%{_sysconfdir}/udev/rules.d/97-bluetooth-ondemand.rules
 %{_sysconfdir}/rc.d/init.d/bluetooth
 %{_localstatedir}/lib/bluetooth
 
@@ -254,6 +258,9 @@ fi
 %config(noreplace) %{_sysconfdir}/sysconfig/pand
 
 %changelog
+* Tue May 05 2009 Petr Lautrbach <plautrba at redhat.com> 4.38-3
+- Start/stop the bluetooth service via udev (#484345)
+
 * Tue May 05 2009 Bastien Nocera <bnocera at redhat.com> 4.38-2
 - Add patch to activate the Socket Mobile CF kit (#498756)
 




More information about the fedora-extras-commits mailing list