summaryrefslogtreecommitdiff
path: root/recipes-connectivity/bluez/bluez5/init
blob: 4d841959ffdfe6ac3a84b897290558870f82155c (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

PATH=/sbin:/bin:/usr/sbin:/usr/bin
DESC=bluetooth

DAEMON=/usr/libexec/bluetooth/bluetoothd

# If you want to be ignore error of "org.freedesktop.hostname1",
# please enable NOPLUGIN_OPTION.
# NOPLUGIN_OPTION="--noplugin=hostname"
NOPLUGIN_OPTION=""
SSD_OPTIONS="--oknodo --quiet --exec $DAEMON -- $NOPLUGIN_OPTION"

test -f $DAEMON || exit 0

# FIXME: any of the sourced files may fail if/with syntax errors
test -f /etc/default/bluetooth && . /etc/default/bluetooth
test -f /etc/default/rcS && . /etc/default/rcS

set -e

case $1 in
  start)
	echo "Starting $DESC"

	if test "$BLUETOOTH_ENABLED" = 0; then
		echo "disabled. see /etc/default/bluetooth"
		exit 0
	fi

	start-stop-daemon --start --background $SSD_OPTIONS $MOREOPTIONS
	sleep 1
        if [[ -n ${BLUETOOTHCTL_CMD} ]] ; then
		echo -e "${BLUETOOTHCTL_CMD}" | /usr/bin/bluetoothctl 2>&1 | logger -t bluetoothctl -p daemon.info
	fi
	echo "${DAEMON##*/}"

  ;;
  stop)
	echo "Stopping $DESC"
	if test "$BLUETOOTH_ENABLED" = 0; then
		echo "disabled."
		exit 0
	fi
	start-stop-daemon --stop $SSD_OPTIONS
	echo "${DAEMON}"
  ;;
  restart|force-reload)
	$0 stop
	sleep 1
	$0 start
  ;;
  status)
	 pidof ${DAEMON} >/dev/null
	 status=$?
        if [ $status -eq 0 ]; then
                 echo "bluetooth is running."
        else
                echo "bluetooth is not running"
        fi
        exit $status
   ;;
   *)
	N=/etc/init.d/bluetooth
	echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
	exit 1
	;;
esac

exit 0

# vim:noet