Add systemd units for monitor and presence

Change-Id: I77593fe6b7927511042aeebff17519719c0742e3
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/meson.build b/meson.build
index c60e1b4..0f4f937 100644
--- a/meson.build
+++ b/meson.build
@@ -18,6 +18,27 @@
 phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
 phosphor_logging = dependency('phosphor-logging')
 sdbusplus = dependency('sdbusplus')
+systemd = dependency('systemd')
+
+systemd_system_unit_dir = systemd.get_pkgconfig_variable(
+    'systemdsystemunitdir',
+    define_variable: ['prefix', get_option('prefix')])
+
+configure_file(
+    copy: true,
+    input: 'phosphor-gpio-monitor@.service',
+    install: true,
+    install_dir: systemd_system_unit_dir,
+    output: 'phosphor-gpio-monitor@.service'
+)
+
+configure_file(
+    copy: true,
+    input: 'phosphor-gpio-presence@.service',
+    install: true,
+    install_dir: systemd_system_unit_dir,
+    output: 'phosphor-gpio-presence@.service'
+)
 
 libevdev_o = static_library(
     'libevdev_o',
diff --git a/phosphor-gpio-monitor@.service b/phosphor-gpio-monitor@.service
new file mode 100644
index 0000000..c1846f8
--- /dev/null
+++ b/phosphor-gpio-monitor@.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Phosphor GPIO %I monitor
+
+[Service]
+Restart=no
+EnvironmentFile=/etc/default/obmc/gpio/%I
+ExecStart=/usr/bin/phosphor-gpio-monitor --path=${{DEVPATH}} --key=${{KEY}} --polarity=${{POLARITY}} --target=${{TARGET}} ${{EXTRA_ARGS}}
diff --git a/phosphor-gpio-presence@.service b/phosphor-gpio-presence@.service
new file mode 100644
index 0000000..6f05371
--- /dev/null
+++ b/phosphor-gpio-presence@.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Phosphor GPIO %I Presence
+Wants=mapper-wait@-xyz-openbmc_project-inventory.service
+After=mapper-wait@-xyz-openbmc_project-inventory.service
+ConditionPathExists=/etc/default/obmc/gpio/phosphor-power-supply-%i.conf
+
+[Service]
+EnvironmentFile={envfiledir}/obmc/gpio/phosphor-power-supply-%i.conf
+ExecStart=/usr/bin/phosphor-gpio-presence --path=${{DEVPATH}} --inventory=${{INVENTORY}} --key=${{KEY}} --name=${{NAME}} --drivers=${{DRIVERS}} --extra-ifaces=${{EXTRA_IFACES}}
+
+[Install]
+RequiredBy=multi-user.target