2008-09-11 02:10:24 +00:00
|
|
|
#!/bin/sh
|
2008-09-12 09:34:05 +00:00
|
|
|
#
|
|
|
|
# chkconfig: 345 50 83
|
|
|
|
# description: Bluetooth services for service discovery, authentication, \
|
|
|
|
# Human Interface Devices, etc.
|
|
|
|
#
|
2008-09-11 02:10:24 +00:00
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Required-Start: $syslog messagebus
|
|
|
|
# Short-Description: Bluetooth services
|
|
|
|
# Description: Bluetooth services for service discovery, authentication,
|
|
|
|
# Human Interface Devices, etc.
|
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
# Source function library.
|
|
|
|
. /etc/rc.d/init.d/functions
|
|
|
|
|
|
|
|
[ -e /etc/sysconfig/bluetooth ] && . /etc/sysconfig/bluetooth
|
|
|
|
|
2009-05-06 11:24:51 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2008-09-11 02:10:24 +00:00
|
|
|
start()
|
|
|
|
{
|
2009-05-06 11:24:51 +00:00
|
|
|
if [ "$BLUETOOTH_ONDEMAND" = "true" ]; then
|
|
|
|
check_condstart || return 1
|
|
|
|
fi
|
|
|
|
|
2008-09-11 02:10:24 +00:00
|
|
|
echo -n $"Starting Bluetooth services:"
|
2008-09-12 09:34:05 +00:00
|
|
|
daemon /usr/sbin/bluetoothd
|
|
|
|
RETVAL=$?
|
|
|
|
[ $RETVAL = 0 ] && touch /var/lock/subsys/bluetoothd
|
2008-09-11 02:10:24 +00:00
|
|
|
[ "$HID2HCI_ENABLE" = "true" ] && hid2hci --tohci > /dev/null 2>&1 || :
|
|
|
|
touch /var/lock/subsys/bluetooth
|
|
|
|
echo ""
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
|
|
|
stop()
|
|
|
|
{
|
|
|
|
echo -n "Stopping Bluetooth services:"
|
|
|
|
[ "$HID2HCI_UNDO" = "true" ] && hid2hci --tohid > /dev/null 2>&1 || :
|
2008-09-12 09:34:05 +00:00
|
|
|
killproc bluetoothd
|
|
|
|
RETVAL=$?
|
2008-09-11 02:10:24 +00:00
|
|
|
rm -f /var/lock/subsys/bluetooth
|
2008-09-12 09:34:05 +00:00
|
|
|
rm -f /var/lock/subsys/bluetoothd
|
2008-09-11 02:10:24 +00:00
|
|
|
echo ""
|
|
|
|
return $RETVAL
|
|
|
|
}
|
|
|
|
|
2009-05-06 11:24:51 +00:00
|
|
|
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 $?
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-09-11 02:10:24 +00:00
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
start
|
|
|
|
;;
|
2009-05-06 11:24:51 +00:00
|
|
|
condstart)
|
|
|
|
condstart
|
|
|
|
;;
|
2008-09-11 02:10:24 +00:00
|
|
|
stop)
|
|
|
|
stop
|
|
|
|
;;
|
2009-05-06 11:24:51 +00:00
|
|
|
condstop)
|
|
|
|
condstop
|
|
|
|
;;
|
2008-09-11 02:10:24 +00:00
|
|
|
force-reload|restart|reload)
|
2009-05-06 11:24:51 +00:00
|
|
|
stop
|
|
|
|
start
|
|
|
|
;;
|
2008-09-11 02:10:24 +00:00
|
|
|
try-restart|condrestart)
|
2009-05-06 11:24:51 +00:00
|
|
|
[ -e /var/lock/subsys/bluetooth ] && (stop; start)
|
|
|
|
;;
|
2008-09-11 02:10:24 +00:00
|
|
|
status)
|
2009-05-06 11:24:51 +00:00
|
|
|
status bluetoothd
|
2008-09-11 02:10:24 +00:00
|
|
|
RETVAL=$?
|
2009-05-06 11:24:51 +00:00
|
|
|
;;
|
2008-09-11 02:10:24 +00:00
|
|
|
*)
|
2009-05-06 11:24:51 +00:00
|
|
|
echo $"Usage: $0 {start|stop|status|restart|reload|condrestart|condstart|condstop}"
|
|
|
|
exit 3
|
2008-09-11 02:10:24 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit $RETVAL
|