From be0d4ad8919e7b7789e853db730d871d8bfc8380 Mon Sep 17 00:00:00 2001 From: Hyuk Lee Date: Mon, 12 Feb 2018 10:13:25 +0900 Subject: [PATCH] Modify the bt-stack-up.sh script Change-Id: I560a461270c4085f21284a2e74ecf2cb1f57e3db Signed-off-by: Hyuk Lee --- packaging/bluetooth-hci-logger-stop.path | 5 +++++ packaging/bluetooth-hci-logger-stop.service | 13 +++++++++++++ packaging/bluetooth-hci-logger.path | 5 +++++ packaging/bluetooth-hci-logger.service | 10 +++++----- packaging/bluetooth-share-start.path | 5 +++++ packaging/bluetooth-share-start.service | 12 ++++++++++++ packaging/bluetooth-tools.spec | 30 +++++++++++++++++++++++++++++ packaging/bluez-start.path | 5 +++++ packaging/bluez-start.service | 12 ++++++++++++ scripts/mobile/bt-stack-down.sh | 2 +- scripts/mobile/bt-stack-up.sh | 12 +----------- 11 files changed, 94 insertions(+), 17 deletions(-) create mode 100644 packaging/bluetooth-hci-logger-stop.path create mode 100644 packaging/bluetooth-hci-logger-stop.service create mode 100644 packaging/bluetooth-hci-logger.path create mode 100644 packaging/bluetooth-share-start.path create mode 100644 packaging/bluetooth-share-start.service create mode 100644 packaging/bluez-start.path create mode 100644 packaging/bluez-start.service diff --git a/packaging/bluetooth-hci-logger-stop.path b/packaging/bluetooth-hci-logger-stop.path new file mode 100644 index 0000000..a0e221b --- /dev/null +++ b/packaging/bluetooth-hci-logger-stop.path @@ -0,0 +1,5 @@ +[Unit] +Description=Path activation for the "bluetooth-hci-logger-stop" + +[Path] +PathExists=/run/.hci_logger_stop diff --git a/packaging/bluetooth-hci-logger-stop.service b/packaging/bluetooth-hci-logger-stop.service new file mode 100644 index 0000000..55d3f18 --- /dev/null +++ b/packaging/bluetooth-hci-logger-stop.service @@ -0,0 +1,13 @@ +[Unit] +Description=Service to stop BT HCI logger normally + +[Service] +Type=oneshot +SmackProcessLabel=System +ExecStartPre=/usr/bin/rm -f /run/.hci_logger_stop +ExecStart=/usr/etc/bluetooth/bt-run-hci-logger.sh normal stop +RemainAfterExit=no +StandardOutput=journal+console +SuccessExitStatus=1 +StartLimitInterval=1 +StartLimitBurst=10 diff --git a/packaging/bluetooth-hci-logger.path b/packaging/bluetooth-hci-logger.path new file mode 100644 index 0000000..0136e39 --- /dev/null +++ b/packaging/bluetooth-hci-logger.path @@ -0,0 +1,5 @@ +[Unit] +Description=Path activation for the "bluetooth-hci-logger" + +[Path] +PathExists=/run/.hci_logger_start diff --git a/packaging/bluetooth-hci-logger.service b/packaging/bluetooth-hci-logger.service index f677940..3fae3a9 100644 --- a/packaging/bluetooth-hci-logger.service +++ b/packaging/bluetooth-hci-logger.service @@ -3,11 +3,11 @@ Description=Service to run BT HCI logger normally [Service] Type=oneshot -User=network_fw -Group=network_fw SmackProcessLabel=System +ExecStartPre=/usr/bin/rm -f /run/.hci_logger_start ExecStart=/usr/etc/bluetooth/bt-run-hci-logger.sh normal start btmon -ExecStop=/usr/etc/bluetooth/bt-run-hci-logger.sh normal stop -RemainAfterExit=yes +RemainAfterExit=no StandardOutput=journal+console -StandardError=inherit +SuccessExitStatus=1 +StartLimitInterval=1 +StartLimitBurst=10 diff --git a/packaging/bluetooth-share-start.path b/packaging/bluetooth-share-start.path new file mode 100644 index 0000000..5a3eefb --- /dev/null +++ b/packaging/bluetooth-share-start.path @@ -0,0 +1,5 @@ +[Unit] +Description=Path activation for the "bluetooth-share-start" + +[Path] +PathExists=/run/.bluetooth_share_start diff --git a/packaging/bluetooth-share-start.service b/packaging/bluetooth-share-start.service new file mode 100644 index 0000000..4a46d01 --- /dev/null +++ b/packaging/bluetooth-share-start.service @@ -0,0 +1,12 @@ +[Unit] +Description=Service to run bluetooth-share normally + +[Service] +Type=oneshot +SmackProcessLabel=System +ExecStartPre=/usr/bin/rm -f /run/.bluetooth_share_start +ExecStart=/usr/bin/systemctl start --no-block bluetooth-share.service +RemainAfterExit=no +SuccessExitStatus=1 +StartLimitInterval=1 +StartLimitBurst=10 diff --git a/packaging/bluetooth-tools.spec b/packaging/bluetooth-tools.spec index 8b0e761..d256a59 100644 --- a/packaging/bluetooth-tools.spec +++ b/packaging/bluetooth-tools.spec @@ -87,16 +87,39 @@ rm -rf %{buildroot} %make_install mkdir -p %{buildroot}%{_prefix}/etc/bluetooth/ +mkdir -p %{buildroot}/run/bluetooth install -m 0755 scripts/bt-dev-start.sh %{buildroot}%{_prefix}/etc/bluetooth/bt-dev-start.sh install -m 0755 scripts/bt-dev-end.sh %{buildroot}%{_prefix}/etc/bluetooth/bt-dev-end.sh install -D -m 0644 packaging/bluetooth-hci-logger.service %{buildroot}%{_libdir}/systemd/system/bluetooth-hci-logger.service +install -D -m 0644 packaging/bluetooth-hci-logger.path %{buildroot}%{_libdir}/systemd/system/bluetooth-hci-logger.path + +install -D -m 0644 packaging/bluetooth-hci-logger-stop.service %{buildroot}%{_libdir}/systemd/system/bluetooth-hci-logger-stop.service +install -D -m 0644 packaging/bluetooth-hci-logger-stop.path %{buildroot}%{_libdir}/systemd/system/bluetooth-hci-logger-stop.path + +install -D -m 0644 packaging/bluez-start.service %{buildroot}%{_libdir}/systemd/system/bluez-start.service +install -D -m 0644 packaging/bluez-start.path %{buildroot}%{_libdir}/systemd/system/bluez-start.path + +install -D -m 0644 packaging/bluetooth-share-start.service %{buildroot}%{_libdir}/systemd/system/bluetooth-share-start.service +install -D -m 0644 packaging/bluetooth-share-start.path %{buildroot}%{_libdir}/systemd/system/bluetooth-share-start.path + install -D -m 0644 packaging/bluetooth-force-hci-logger.service %{buildroot}%{_libdir}/systemd/system/bluetooth-force-hci-logger.service install -D -m 0644 packaging/bluetooth-hci-dump@.service %{buildroot}%{_libdir}/systemd/system/bluetooth-hci-dump@.service %post mkdir -p %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/ ln -sf %{_libdir}/systemd/system/bluetooth-hci-logger.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/ +ln -sf %{_libdir}/systemd/system/bluetooth-hci-logger.path %{_libdir}/systemd/system/multi-user.target.wants/bluetooth-hci-logger.path + +ln -sf %{_libdir}/systemd/system/bluetooth-hci-logger-stop.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/ +ln -sf %{_libdir}/systemd/system/bluetooth-hci-logger-stop.path %{_libdir}/systemd/system/multi-user.target.wants/bluetooth-hci-logger-stop.path + +ln -sf %{_libdir}/systemd/system/bluez-start.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/ +ln -sf %{_libdir}/systemd/system/bluez-start.path %{_libdir}/systemd/system/multi-user.target.wants/bluez-start.path + +ln -sf %{_libdir}/systemd/system/bluetooth-share-start.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/ +ln -sf %{_libdir}/systemd/system/bluetooth-share-start.path %{_libdir}/systemd/system/multi-user.target.wants/bluetooth-share-start.path + ln -sf %{_libdir}/systemd/system/bluetooth-force-hci-logger.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/ @@ -116,6 +139,13 @@ ln -sf %{_libdir}/systemd/system/bluetooth-force-hci-logger.service %{_sysconfdi #%{_unitdir}/multi-user.target.wants/bluetooth-address.service #%{_unitdir}/bluetooth-address.service %{_libdir}/systemd/system/bluetooth-hci-logger.service +%{_libdir}/systemd/system/bluetooth-hci-logger.path +%{_libdir}/systemd/system/bluetooth-hci-logger-stop.service +%{_libdir}/systemd/system/bluetooth-hci-logger-stop.path +%{_libdir}/systemd/system/bluez-start.service +%{_libdir}/systemd/system/bluez-start.path +%{_libdir}/systemd/system/bluetooth-share-start.service +%{_libdir}/systemd/system/bluetooth-share-start.path %{_libdir}/systemd/system/bluetooth-force-hci-logger.service %{_libdir}/systemd/system/bluetooth-hci-dump@.service diff --git a/packaging/bluez-start.path b/packaging/bluez-start.path new file mode 100644 index 0000000..2f63af9 --- /dev/null +++ b/packaging/bluez-start.path @@ -0,0 +1,5 @@ +[Unit] +Description=Path activation for the "bluez" + +[Path] +PathExists=/run/.bluez_start diff --git a/packaging/bluez-start.service b/packaging/bluez-start.service new file mode 100644 index 0000000..804a615 --- /dev/null +++ b/packaging/bluez-start.service @@ -0,0 +1,12 @@ +[Unit] +Description=Service to run Bluetoothd normally + +[Service] +Type=oneshot +SmackProcessLabel=System +ExecStartPre=/usr/bin/rm -f /run/.bluez_start +ExecStart=/usr/bin/systemctl start --no-block bluetooth.service +RemainAfterExit=yes +SuccessExitStatus=1 +StartLimitInterval=1 +StartLimitBurst=10 diff --git a/scripts/mobile/bt-stack-down.sh b/scripts/mobile/bt-stack-down.sh index 1415d58..0f8926f 100644 --- a/scripts/mobile/bt-stack-down.sh +++ b/scripts/mobile/bt-stack-down.sh @@ -9,7 +9,7 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin /usr/etc/bluetooth/bt-dev-end.sh # Stop HCI logging -systemctl stop bluetooth-hci-logger.service +/usr/bin/touch /run/.hci_logger_stop # Kill BlueZ bluetooth stack killall obexd obex-client diff --git a/scripts/mobile/bt-stack-up.sh b/scripts/mobile/bt-stack-up.sh index 015d351..ddbf664 100644 --- a/scripts/mobile/bt-stack-up.sh +++ b/scripts/mobile/bt-stack-up.sh @@ -5,23 +5,13 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin # Script for executing Bluetooth stack # -# Start HCI logging -systemctl start bluetooth-hci-logger.service - # Register BT Device /usr/etc/bluetooth/bt-dev-start.sh if !(/usr/bin/hciconfig | grep hci); then echo "Registering BT device is failed." - systemctl stop bluetooth-hci-logger.service + /usr/bin/touch /run/.hci_logger_stop exit 1 fi -# Execute BlueZ BT stack -echo "Run bluetoothd" -/usr/libexec/bluetooth/bluetoothd -d -C & - -echo "Run bluetooth-share by systemd" -systemctl start --no-block bluetooth-share.service - exit 0 -- 2.7.4