summaryrefslogtreecommitdiffstats
path: root/scripts/bluetooth.rc.rh
blob: f0586788611d89bfb4f5f7dea9c1f8639aa147a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/sh
#
# bluetooth    Bluetooth subsystem starting and stopping
#
# chkconfig: 345 25 90
# description: Bluetooth subsystem
#

# Source function library.
. /etc/rc.d/init.d/functions

# Source Bluetooth configuration.
#. /etc/sysconfig/bluetooth

prog="Bluetooth"

UART_CONF="/etc/bluetooth/uart"

start_uarts() 
{
	[ -f /sbin/hciattach -a -f $UART_CONF ] || return
	grep -v '^#' $UART_CONF | while read i; do
		/sbin/hciattach $i
	done
}

stop_uarts()
{
	killproc hciattach > /dev/null 2>&1
}

start() 
{
        echo -n $"Starting $prog: "
        daemon /sbin/hcid
	start_uarts
	touch  /var/lock/subsys/bluetooth
        echo
}

stop() 
{
        echo -n $"Shutting down $prog: "
	stop_uarts
	killproc hcid
	rm -f  /var/lock/subsys/bluetooth
        echo
}

[ -f /sbin/hcid ] || exit 0

# See how we were called.
case "$1" in
  start)
	start
        ;;
  stop)
	stop
        ;;
  restart|reload)
	stop
	start
	;;
  condrestart)
	[ -e /var/lock/subsys/bluetooth ] && (stop; start)
	;;
  *)
        echo $"Usage: $0 {start|stop|restart|reload|condrestart}"
        exit 1
esac

exit 0