- Start/stop the bluetooth service via udev (#484345)
This commit is contained in:
parent
4d7d9d55ac
commit
962744352b
3
97-bluetooth-ondemand.rules
Normal file
3
97-bluetooth-ondemand.rules
Normal file
@ -0,0 +1,3 @@
|
||||
#bluetooth on demand rules
|
||||
SUBSYSTEM=="bluetooth", ACTION=="add", RUN+="/sbin/service bluetooth condstart"
|
||||
SUBSYSTEM=="bluetooth", ACTION=="remove", RUN+="/sbin/service bluetooth condstop"
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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 = %{version}
|
||||
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/cups ; then
|
||||
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@redhat.com> 4.38-3
|
||||
- Start/stop the bluetooth service via udev (#484345)
|
||||
|
||||
* Tue May 05 2009 Bastien Nocera <bnocera@redhat.com> 4.38-2
|
||||
- Add patch to activate the Socket Mobile CF kit (#498756)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user