3b144b2d52ebad820f820622c2686db50c4f5ed0
[platform/core/connectivity/bluetooth-tools.git] / scripts / mobile / bt-stack-up.sh
1 #!/bin/sh
2 PATH=/bin:/usr/bin:/sbin:/usr/sbin
3
4 #
5 # Script for executing Bluetooth stack
6 #
7
8 # Start HCI logging
9 systemctl start bluetooth-hci-logger.service
10
11 # Register BT Device
12 /usr/etc/bluetooth/bt-dev-start.sh
13
14 if !(/usr/bin/hciconfig | grep hci); then
15         echo "Registering BT device is failed."
16         systemctl stop bluetooth-hci-logger.service
17         exit 1
18 fi
19
20 # We have to handle both systemd and sysvinit cases differently
21 if [ -d /sys/fs/cgroup/systemd ]; then
22    # bt-service changes USER to 'app' via libprivilege-control, so it needs
23    # to know where the session bus is located under systemd
24    export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/app/dbus/user_bus_socket
25 fi
26
27 # Execute BlueZ BT stack
28 echo "Run bluetoothd"
29 /usr/libexec/bluetooth/bluetoothd -d -C &
30
31 echo "Run bluetooth-share by systemd"
32 systemctl start --no-block bluetooth-share.service
33
34 exit 0