- Switch to on-demand start/stop using udev
This commit is contained in:
parent
28d541380f
commit
c6e2f31622
@ -1,3 +0,0 @@
|
|||||||
#bluetooth on demand rules
|
|
||||||
SUBSYSTEM=="bluetooth", ACTION=="add", RUN+="/sbin/service bluetooth condstart"
|
|
||||||
SUBSYSTEM=="bluetooth", ACTION=="remove", RUN+="/sbin/service bluetooth condstop"
|
|
30
bluetooth-check
Executable file
30
bluetooth-check
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Run "initctl log-priority info" to get debug from
|
||||||
|
# upstart about events being processed, or pass
|
||||||
|
# --debug to your kernel arguments
|
||||||
|
|
||||||
|
emit_event()
|
||||||
|
{
|
||||||
|
/sbin/initctl emit --no-wait $1
|
||||||
|
}
|
||||||
|
|
||||||
|
# If any of those paths are read-only, bail
|
||||||
|
if `mount | grep "on / type" | grep -q ro` ; then
|
||||||
|
return 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the action is add, we always have an adapter
|
||||||
|
if test "x$ACTION" = "xadd" ; then
|
||||||
|
emit_event fedora.bluetooth-adapter-available
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Check whether any devices are available
|
||||||
|
if `udevadm info --export-db | grep -q -e '/devices/.*/bluetooth/.*'` ; then
|
||||||
|
emit_event fedora.bluetooth-adapter-available
|
||||||
|
else
|
||||||
|
emit_event fedora.bluetooth-adapter-not-available
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
@ -4,7 +4,4 @@
|
|||||||
|
|
||||||
# Enable this to switch capable devices back to HID mode on Bluetooth shutdown
|
# Enable this to switch capable devices back to HID mode on Bluetooth shutdown
|
||||||
#HID2HCI_UNDO=true
|
#HID2HCI_UNDO=true
|
||||||
#
|
|
||||||
#Enable this to allow automatic start or stop when bluetooth
|
|
||||||
#inserted or removed
|
|
||||||
#BLUETOOTH_ONDEMAND=true
|
|
||||||
|
101
bluetooth.init
101
bluetooth.init
@ -1,14 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# chkconfig: 345 50 83
|
# chkconfig: 345 50 83
|
||||||
# description: Bluetooth services for service discovery, authentication, \
|
# description: Turn HID adapters into Bluetooth ones
|
||||||
# Human Interface Devices, etc.
|
|
||||||
#
|
#
|
||||||
### BEGIN INIT INFO
|
### BEGIN INIT INFO
|
||||||
# Required-Start: $syslog messagebus
|
# Short-Description: Turn HID adapters into Bluetooth ones
|
||||||
# Short-Description: Bluetooth services
|
# Description: Turn HID adapters into Bluetooth ones
|
||||||
# Description: Bluetooth services for service discovery, authentication,
|
|
||||||
# Human Interface Devices, etc.
|
|
||||||
### END INIT INFO
|
### END INIT INFO
|
||||||
|
|
||||||
# Source function library.
|
# Source function library.
|
||||||
@ -16,54 +13,11 @@
|
|||||||
|
|
||||||
[ -e /etc/sysconfig/bluetooth ] && . /etc/sysconfig/bluetooth
|
[ -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()
|
start()
|
||||||
{
|
{
|
||||||
if [ "$BLUETOOTH_ONDEMAND" = "true" ]; then
|
echo -n $"Starting hid2hci:"
|
||||||
check_condstart || return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo -n $"Starting Bluetooth services:"
|
|
||||||
daemon /usr/sbin/bluetoothd
|
|
||||||
RETVAL=$?
|
|
||||||
[ $RETVAL = 0 ] && touch /var/lock/subsys/bluetoothd
|
|
||||||
[ "$HID2HCI_ENABLE" = "true" ] && hid2hci --tohci > /dev/null 2>&1 || :
|
[ "$HID2HCI_ENABLE" = "true" ] && hid2hci --tohci > /dev/null 2>&1 || :
|
||||||
|
RETVAL=$?
|
||||||
touch /var/lock/subsys/bluetooth
|
touch /var/lock/subsys/bluetooth
|
||||||
echo ""
|
echo ""
|
||||||
return $RETVAL
|
return $RETVAL
|
||||||
@ -73,64 +27,23 @@ stop()
|
|||||||
{
|
{
|
||||||
echo -n "Stopping Bluetooth services:"
|
echo -n "Stopping Bluetooth services:"
|
||||||
[ "$HID2HCI_UNDO" = "true" ] && hid2hci --tohid > /dev/null 2>&1 || :
|
[ "$HID2HCI_UNDO" = "true" ] && hid2hci --tohid > /dev/null 2>&1 || :
|
||||||
killproc bluetoothd
|
|
||||||
RETVAL=$?
|
RETVAL=$?
|
||||||
rm -f /var/lock/subsys/bluetooth
|
|
||||||
rm -f /var/lock/subsys/bluetoothd
|
|
||||||
echo ""
|
echo ""
|
||||||
return $RETVAL
|
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
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
start
|
start
|
||||||
;;
|
;;
|
||||||
condstart)
|
|
||||||
condstart
|
|
||||||
;;
|
|
||||||
stop)
|
stop)
|
||||||
stop
|
stop
|
||||||
;;
|
;;
|
||||||
condstop)
|
|
||||||
condstop
|
|
||||||
;;
|
|
||||||
force-reload|restart|reload)
|
|
||||||
stop
|
|
||||||
start
|
|
||||||
;;
|
|
||||||
try-restart|condrestart)
|
|
||||||
[ -e /var/lock/subsys/bluetooth ] && (stop; start)
|
|
||||||
;;
|
|
||||||
status)
|
status)
|
||||||
status bluetoothd
|
RETVAL=0
|
||||||
RETVAL=$?
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart|condstart|condstop}"
|
echo $"Usage: $0 {start|stop|status}"
|
||||||
exit 3
|
exit 3
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
10
bluez
Normal file
10
bluez
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# Automatically start bluetoothd when an adapter is plugged in
|
||||||
|
#
|
||||||
|
|
||||||
|
start on fedora.bluetooth-adapter-available
|
||||||
|
|
||||||
|
stop on runlevel [016]
|
||||||
|
stop on fedora.bluetooth-adapter-not-available
|
||||||
|
|
||||||
|
exec /usr/sbin/bluetoothd --nodaemon
|
||||||
|
|
15
bluez.spec
15
bluez.spec
@ -1,7 +1,7 @@
|
|||||||
Summary: Bluetooth utilities
|
Summary: Bluetooth utilities
|
||||||
Name: bluez
|
Name: bluez
|
||||||
Version: 4.41
|
Version: 4.41
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
License: GPLv2+
|
License: GPLv2+
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
Source: http://www.kernel.org/pub/linux/bluetooth/%{name}-%{version}.tar.gz
|
Source: http://www.kernel.org/pub/linux/bluetooth/%{name}-%{version}.tar.gz
|
||||||
@ -13,7 +13,8 @@ Source5: pand.init
|
|||||||
Source6: pand.conf
|
Source6: pand.conf
|
||||||
Source7: rfcomm.init
|
Source7: rfcomm.init
|
||||||
Source8: bluez-uinput.modules
|
Source8: bluez-uinput.modules
|
||||||
Source9: 97-bluetooth-ondemand.rules
|
Source9: 96-bluez.rules
|
||||||
|
|
||||||
Patch1: bluez-utils-oui-usage.patch
|
Patch1: bluez-utils-oui-usage.patch
|
||||||
# https://bugzilla.redhat.com/show_bug.cgi?id=450081
|
# https://bugzilla.redhat.com/show_bug.cgi?id=450081
|
||||||
# http://thread.gmane.org/gmane.linux.bluez.kernel/1687
|
# http://thread.gmane.org/gmane.linux.bluez.kernel/1687
|
||||||
@ -24,6 +25,8 @@ Patch3: bluez-activate-wacom-mode2.patch
|
|||||||
Patch4: bluez-socket-mobile-cf-connection-kit.patch
|
Patch4: bluez-socket-mobile-cf-connection-kit.patch
|
||||||
# http://thread.gmane.org/gmane.linux.bluez.kernel/2396
|
# http://thread.gmane.org/gmane.linux.bluez.kernel/2396
|
||||||
Patch5: 0001-Add-sixaxis-cable-pairing-plugin.patch
|
Patch5: 0001-Add-sixaxis-cable-pairing-plugin.patch
|
||||||
|
# http://thread.gmane.org/gmane.linux.bluez.kernel/2474
|
||||||
|
Patch6: 0001-Add-udev-mode-to-bluetoothd.patch
|
||||||
|
|
||||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
|
||||||
URL: http://www.bluez.org/
|
URL: http://www.bluez.org/
|
||||||
@ -129,6 +132,7 @@ This includes hidd, dund and pand.
|
|||||||
%patch3 -p1 -b .wacom
|
%patch3 -p1 -b .wacom
|
||||||
%patch4 -p1 -b .socket-mobile
|
%patch4 -p1 -b .socket-mobile
|
||||||
%patch5 -p1 -b .cable-pairing
|
%patch5 -p1 -b .cable-pairing
|
||||||
|
%patch6 -p1 -b .udev
|
||||||
|
|
||||||
%build
|
%build
|
||||||
libtoolize -f -c
|
libtoolize -f -c
|
||||||
@ -161,8 +165,8 @@ fi
|
|||||||
|
|
||||||
rm -f ${RPM_BUILD_ROOT}/%{_sysconfdir}/udev/*.rules
|
rm -f ${RPM_BUILD_ROOT}/%{_sysconfdir}/udev/*.rules
|
||||||
install -D -m0644 scripts/bluetooth-serial.rules ${RPM_BUILD_ROOT}/%{_sysconfdir}/udev/rules.d/97-bluetooth-serial.rules
|
install -D -m0644 scripts/bluetooth-serial.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 scripts/bluetooth_serial ${RPM_BUILD_ROOT}/lib/udev/bluetooth_serial
|
||||||
|
install -D -m0644 %{SOURCE9} ${RPM_BUILD_ROOT}/lib/udev/rules.d/96-bluez.rules
|
||||||
|
|
||||||
install -D -m0755 %{SOURCE8} $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/modules/bluez-uinput.modules
|
install -D -m0755 %{SOURCE8} $RPM_BUILD_ROOT/%{_sysconfdir}/sysconfig/modules/bluez-uinput.modules
|
||||||
|
|
||||||
@ -227,8 +231,8 @@ fi
|
|||||||
%config %{_sysconfdir}/dbus-1/system.d/bluetooth.conf
|
%config %{_sysconfdir}/dbus-1/system.d/bluetooth.conf
|
||||||
%{_libdir}/bluetooth/
|
%{_libdir}/bluetooth/
|
||||||
/lib/udev/bluetooth_serial
|
/lib/udev/bluetooth_serial
|
||||||
|
/lib/udev/rules.d/96-bluez.rules
|
||||||
%{_sysconfdir}/udev/rules.d/97-bluetooth-serial.rules
|
%{_sysconfdir}/udev/rules.d/97-bluetooth-serial.rules
|
||||||
%{_sysconfdir}/udev/rules.d/97-bluetooth-ondemand.rules
|
|
||||||
%{_sysconfdir}/rc.d/init.d/bluetooth
|
%{_sysconfdir}/rc.d/init.d/bluetooth
|
||||||
%{_localstatedir}/lib/bluetooth
|
%{_localstatedir}/lib/bluetooth
|
||||||
|
|
||||||
@ -269,6 +273,9 @@ fi
|
|||||||
%config(noreplace) %{_sysconfdir}/sysconfig/pand
|
%config(noreplace) %{_sysconfdir}/sysconfig/pand
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Thu Jun 11 2009 Bastien Nocera <bnocera@redhat.com> 4.41-2
|
||||||
|
- Switch to on-demand start/stop using udev
|
||||||
|
|
||||||
* Mon Jun 08 2009 Bastien Nocera <bnocera@redhat.com> 4.41-1
|
* Mon Jun 08 2009 Bastien Nocera <bnocera@redhat.com> 4.41-1
|
||||||
- Update to 4.41
|
- Update to 4.41
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user