All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 0/2 v2] Add support for systemd mesh service
@ 2019-05-31 18:54 Inga Stotland
  2019-05-31 18:54 ` [PATCH BlueZ 1/2 v2] build: Add support for systemd bluetooth-mesh service Inga Stotland
  2019-05-31 18:54 ` [PATCH BlueZ 2/2 v2] mesh: Do not daemonize, run in foreground or as service Inga Stotland
  0 siblings, 2 replies; 3+ messages in thread
From: Inga Stotland @ 2019-05-31 18:54 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: brian.gix, johan.hedberg, luiz.dentz, Inga Stotland

With whitespace fix

This patch set adds files necessary to run bluetooth-mesh as
systemd service. Also removes explicit call to daemon()

Inga Stotland (2):
  build: Add support for systemd bluetooth-mesh service
  mesh: Do not daemonize, run in foreground or as service

 Makefile.am                    |  2 +-
 Makefile.mesh                  | 14 ++++++++++++--
 mesh/bluetooth-mesh.service.in | 12 ++++++++++++
 mesh/main.c                    | 15 +++++----------
 mesh/org.bluez.mesh.service    |  5 +++++
 5 files changed, 35 insertions(+), 13 deletions(-)
 create mode 100644 mesh/bluetooth-mesh.service.in
 create mode 100644 mesh/org.bluez.mesh.service

-- 
2.21.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH BlueZ 1/2 v2] build: Add support for systemd bluetooth-mesh service
  2019-05-31 18:54 [PATCH BlueZ 0/2 v2] Add support for systemd mesh service Inga Stotland
@ 2019-05-31 18:54 ` Inga Stotland
  2019-05-31 18:54 ` [PATCH BlueZ 2/2 v2] mesh: Do not daemonize, run in foreground or as service Inga Stotland
  1 sibling, 0 replies; 3+ messages in thread
From: Inga Stotland @ 2019-05-31 18:54 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: brian.gix, johan.hedberg, luiz.dentz, Inga Stotland

This adds support for installing systemd bluetooth-mesh service unit
and dbus service file that references this systemd unit.
---
 Makefile.am                    |  2 +-
 Makefile.mesh                  | 14 ++++++++++++--
 mesh/bluetooth-mesh.service.in | 12 ++++++++++++
 mesh/org.bluez.mesh.service    |  5 +++++
 4 files changed, 30 insertions(+), 3 deletions(-)
 create mode 100644 mesh/bluetooth-mesh.service.in
 create mode 100644 mesh/org.bluez.mesh.service

diff --git a/Makefile.am b/Makefile.am
index f84a1faba..3f398dc5a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -560,7 +560,7 @@ SED_PROCESS = $(AM_V_GEN)$(MKDIR_P) $(dir $@) && \
 		$(SED) -e 's,@pkglibexecdir\@,$(pkglibexecdir),g' \
 		< $< > $@
 
-%.service: %.service.in Makefile
+%.service: %.service.in Makefile Makefile.mesh
 	$(SED_PROCESS)
 
 %.1: %.txt
diff --git a/Makefile.mesh b/Makefile.mesh
index d494287ab..9cd6e73d6 100644
--- a/Makefile.mesh
+++ b/Makefile.mesh
@@ -4,6 +4,11 @@ if DATAFILES
 dbus_DATA += mesh/bluetooth-mesh.conf
 endif
 
+if SYSTEMD
+systemdsystemunit_DATA += mesh/bluetooth-mesh.service
+dbussystembus_DATA += mesh/org.bluez.mesh.service
+endif
+
 mesh_sources = mesh/mesh.h mesh/mesh.c \
 				mesh/net-keys.h mesh/net-keys.c \
 				mesh/mesh-io.h mesh/mesh-io.c \
@@ -32,7 +37,12 @@ libexec_PROGRAMS += mesh/bluetooth-meshd
 
 mesh_bluetooth_meshd_SOURCES = $(mesh_sources) mesh/main.c
 mesh_bluetooth_meshd_LDADD = src/libshared-ell.la $(ell_ldadd) -ljson-c
-mesh_bluetooth_meshd_DEPENDENCIES = $(ell_dependencies) src/libshared-ell.la
+mesh_bluetooth_meshd_DEPENDENCIES = $(ell_dependencies) src/libshared-ell.la \
+				mesh/bluetooth-mesh.service
+
+EXTRA_DIST += mesh/bluetooth-mesh.conf mesh/bluetooth-mesh.service.in \
+		mesh/org.bluez.mesh.service
+
+CLEANFILES += mesh/bluetooth-mesh.service
 
-EXTRA_DIST += mesh/bluetooth-mesh.conf
 endif
diff --git a/mesh/bluetooth-mesh.service.in b/mesh/bluetooth-mesh.service.in
new file mode 100644
index 000000000..36f2a1d4a
--- /dev/null
+++ b/mesh/bluetooth-mesh.service.in
@@ -0,0 +1,12 @@
+[Unit]
+Description=Bluetooth mesh service
+ConditionPathIsDirectory=/sys/class/bluetooth
+
+[Service]
+Type=dbus
+BusName=org.bluez.mesh
+ExecStart=@pkglibexecdir@/bluetooth-meshd
+NotifyAccess=main
+LimitNPROC=1
+ProtectHome=true
+ProtectSystem=full
diff --git a/mesh/org.bluez.mesh.service b/mesh/org.bluez.mesh.service
new file mode 100644
index 000000000..a61c44455
--- /dev/null
+++ b/mesh/org.bluez.mesh.service
@@ -0,0 +1,5 @@
+[D-BUS Service]
+Name=org.bluez.mesh
+Exec=/bin/false
+User=root
+SystemdService=dbus-org.bluez.mesh.service
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH BlueZ 2/2 v2] mesh: Do not daemonize, run in foreground or as service
  2019-05-31 18:54 [PATCH BlueZ 0/2 v2] Add support for systemd mesh service Inga Stotland
  2019-05-31 18:54 ` [PATCH BlueZ 1/2 v2] build: Add support for systemd bluetooth-mesh service Inga Stotland
@ 2019-05-31 18:54 ` Inga Stotland
  1 sibling, 0 replies; 3+ messages in thread
From: Inga Stotland @ 2019-05-31 18:54 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: brian.gix, johan.hedberg, luiz.dentz, Inga Stotland

This removes call to daemon(). "--node-detach" option is retained
to set umask().

Also, adds description for dbus-debug option.
---
 mesh/main.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/mesh/main.c b/mesh/main.c
index a621300e6..1c7123cc1 100644
--- a/mesh/main.c
+++ b/mesh/main.c
@@ -2,7 +2,7 @@
  *
  *  BlueZ - Bluetooth protocol stack for Linux
  *
- *  Copyright (C) 2017-2018  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2017-2019  Intel Corporation. All rights reserved.
  *
  *
  *  This library is free software; you can redistribute it and/or
@@ -41,6 +41,7 @@ static const struct option main_options[] = {
 	{ "config",	optional_argument,	NULL, 'c' },
 	{ "nodetach",	no_argument,		NULL, 'n' },
 	{ "debug",	no_argument,		NULL, 'd' },
+	{ "dbus-debug",	no_argument,		NULL, 'b' },
 	{ "help",	no_argument,		NULL, 'h' },
 	{ }
 };
@@ -55,6 +56,7 @@ static void usage(void)
 	       "\t--config          Configuration directory\n"
 	       "\t--nodetach        Run in foreground\n"
 	       "\t--debug           Enable debug output\n"
+	       "\t--dbus-debug      Enable D-Bus debugging\n"
 	       "\t--help            Show %s information\n", __func__);
 }
 
@@ -170,7 +172,8 @@ int main(int argc, char *argv[])
 		goto done;
 	}
 
-	umask(0077);
+	if (!detached)
+		umask(0077);
 
 	dbus = l_dbus_new_default(L_DBUS_SYSTEM_BUS);
 	if (!dbus) {
@@ -190,14 +193,6 @@ int main(int argc, char *argv[])
 		goto done;
 	}
 
-	if (detached) {
-		if (daemon(0, 0)) {
-			perror("Failed to start meshd daemon");
-			status = EXIT_FAILURE;
-			goto done;
-		}
-	}
-
 	status = l_main_run_with_signal(signal_handler, NULL);
 
 done:
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-05-31 18:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31 18:54 [PATCH BlueZ 0/2 v2] Add support for systemd mesh service Inga Stotland
2019-05-31 18:54 ` [PATCH BlueZ 1/2 v2] build: Add support for systemd bluetooth-mesh service Inga Stotland
2019-05-31 18:54 ` [PATCH BlueZ 2/2 v2] mesh: Do not daemonize, run in foreground or as service Inga Stotland

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.