presence: Add service file to repo
This adds the fan presence service files, one for YAML mode and a
different one for JSON mode, to the repository. Which one is installed
is based on the --enable-json value.
The JSON mode service file is designed to start as part of the system
reaching the multi-user target. The YAML mode service file is designed
to start when the chassis is powered on.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ifd65c98a0d8eab83a06c303221e4b4c69c4a0f7b
diff --git a/presence/Makefile.am b/presence/Makefile.am
index af66bbd..2affa91 100644
--- a/presence/Makefile.am
+++ b/presence/Makefile.am
@@ -4,6 +4,16 @@
bin_PROGRAMS = \
phosphor-fan-presence-tach
+systemdsystemunit_DATA=
+
+if WANT_JSON
+systemdsystemunit_DATA += \
+ service_files/json/phosphor-fan-presence-tach@.service
+else
+systemdsystemunit_DATA += \
+ service_files/yaml/phosphor-fan-presence-tach@.service
+endif
+
phosphor_fan_presence_tach_SOURCES = \
anyof.cpp \
error_reporter.cpp \
diff --git a/presence/service_files/json/phosphor-fan-presence-tach@.service.in b/presence/service_files/json/phosphor-fan-presence-tach@.service.in
new file mode 100644
index 0000000..78b90cb
--- /dev/null
+++ b/presence/service_files/json/phosphor-fan-presence-tach@.service.in
@@ -0,0 +1,7 @@
+[Unit]
+Description=Phosphor Fan Presence Tach Daemon
+After=mapper-wait@-xyz-openbmc_project-inventory.service
+
+[Service]
+Restart=on-failure
+ExecStart=@BINDIR@/phosphor-fan-presence-tach
diff --git a/presence/service_files/yaml/phosphor-fan-presence-tach@.service.in b/presence/service_files/yaml/phosphor-fan-presence-tach@.service.in
new file mode 100644
index 0000000..6afaf74
--- /dev/null
+++ b/presence/service_files/yaml/phosphor-fan-presence-tach@.service.in
@@ -0,0 +1,13 @@
+[Unit]
+Description=Phosphor Fan Presence Tach Daemon
+Wants=obmc-power-on@%i.target
+After=obmc-power-on@%i.target
+Conflicts=obmc-chassis-powered-off@%i.target
+
+[Service]
+Restart=on-failure
+ExecStart=@BINDIR@/phosphor-fan-presence-tach
+SyslogIdentifier=phosphor-fan-presence-tach
+
+[Install]
+RequiredBy=obmc-chassis-poweron@%i.target