mapper: install systemd unit, dbus conf files
The same systemd and dbus unit/configuration files can work for everyone
now, so ship them. Enable dbus activation, add unit file templates, and
move mapperx to libexec where it belongs.
Change-Id: Ieb021889605767ffdb9d72faad5f5b856312b935
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/meson.build b/meson.build
index 124b37a..3f24805 100644
--- a/meson.build
+++ b/meson.build
@@ -106,9 +106,49 @@
dependency('threads'),
dependency('tinyxml2'),
],
- install: true
+ install: true,
+ install_dir: join_paths(
+ get_option('prefix'), get_option('libexecdir'), meson.project_name())
)
+systemd_system_unit_dir = dependency('systemd').get_variable(
+ pkgconfig : 'systemdsystemunitdir'
+)
+
+conf = configuration_data()
+conf.set('BINDIR', join_paths(get_option('prefix'), get_option('bindir')))
+conf.set('LIBEXECDIR', join_paths(
+ get_option('prefix'), get_option('libexecdir')))
+
+unit_files = [
+ 'xyz.openbmc_project.ObjectMapper.service',
+ 'mapper-subtree-remove@.service',
+ 'mapper-wait@.service'
+]
+
+foreach u : unit_files
+ configure_file(
+ configuration: conf,
+ input : join_paths('src/systemd', u) + '.in',
+ install : true,
+ install_dir: systemd_system_unit_dir,
+ output : u
+ )
+endforeach
+
+dbus_system_bus_services_dir = dependency('dbus-1').get_variable(
+ pkgconfig: 'system_bus_services_dir',
+ pkgconfig_define: ['prefix', get_option('prefix')]
+)
+
+install_data(
+ 'src/dbus/xyz.openbmc_project.ObjectMapper.service',
+ install_dir: dbus_system_bus_services_dir)
+
+install_data(
+ 'src/dbus/xyz.openbmc_project.ObjectMapper.conf',
+ install_dir: get_option('datadir') / 'dbus-1' / 'system.d')
+
executable(
'phosphor-unit-failure-monitor',
[
diff --git a/src/dbus/xyz.openbmc_project.ObjectMapper.conf b/src/dbus/xyz.openbmc_project.ObjectMapper.conf
new file mode 100644
index 0000000..3d9fcc3
--- /dev/null
+++ b/src/dbus/xyz.openbmc_project.ObjectMapper.conf
@@ -0,0 +1,8 @@
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+ <policy user="root">
+ <allow own="xyz.openbmc_project.ObjectMapper"/>
+ <allow send_destination="xyz.openbmc_project.ObjectMapper"/>
+ </policy>
+</busconfig>
diff --git a/src/dbus/xyz.openbmc_project.ObjectMapper.service b/src/dbus/xyz.openbmc_project.ObjectMapper.service
new file mode 100644
index 0000000..9636606
--- /dev/null
+++ b/src/dbus/xyz.openbmc_project.ObjectMapper.service
@@ -0,0 +1,5 @@
+[D-BUS Service]
+Name=xyz.openbmc_project.ObjectMapper
+Exec=/bin/false
+User=root
+SystemdService=dbus-xyz.openbmc_project.ObjectMapper.service
diff --git a/src/systemd/mapper-subtree-remove@.service.in b/src/systemd/mapper-subtree-remove@.service.in
new file mode 100644
index 0000000..c6a224b
--- /dev/null
+++ b/src/systemd/mapper-subtree-remove@.service.in
@@ -0,0 +1,9 @@
+[Unit]
+Description=mapper subtree-remove %I
+
+[Service]
+Type=oneshot
+RemainAfterExit=no
+Restart=on-failure
+TimeoutStartSec=infinity
+ExecStart=@BINDIR@/mapper subtree-remove %I
diff --git a/src/systemd/mapper-wait@.service.in b/src/systemd/mapper-wait@.service.in
new file mode 100644
index 0000000..a3df21f
--- /dev/null
+++ b/src/systemd/mapper-wait@.service.in
@@ -0,0 +1,9 @@
+[Unit]
+Description=Wait for %I
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+Restart=on-failure
+TimeoutStartSec=infinity
+ExecStart=@BINDIR@/mapper wait %I
diff --git a/src/systemd/xyz.openbmc_project.ObjectMapper.service.in b/src/systemd/xyz.openbmc_project.ObjectMapper.service.in
new file mode 100644
index 0000000..c14ba64
--- /dev/null
+++ b/src/systemd/xyz.openbmc_project.ObjectMapper.service.in
@@ -0,0 +1,14 @@
+[Unit]
+Description=Phosphor DBus Service Discovery Manager
+
+[Service]
+Restart=always
+Type=dbus
+ExecStart=@LIBEXECDIR@/phosphor-objmgr/mapperx
+BusName=xyz.openbmc_project.ObjectMapper
+TimeoutStartSec=300
+RestartSec=5
+
+[Install]
+WantedBy=multi-user.target
+Alias=dbus-xyz.openbmc_project.ObjectMapper.service