Add hwmon systemd unit and udev rule
The udev rule invokes phosphor-hwmon with the
devicetree path of the hwmon device.
The systemd unit is a templated on the devicetree path,
which is forwarded directly to phosphor-hwmon. The
phosphor-hwmon environment file is also templated, so
environment files must be placed in a devicetree
like-named directory tree under
/etc/defaults/obmc/hwmon/<dtreepath>.conf
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Change-Id: I5001f03ace34cb4e39c82270a98c0c3c902a6e63
diff --git a/common/recipes-phosphor/sensors/phosphor-hwmon/70-hwmon.rules b/common/recipes-phosphor/sensors/phosphor-hwmon/70-hwmon.rules
new file mode 100644
index 0000000..070d88f
--- /dev/null
+++ b/common/recipes-phosphor/sensors/phosphor-hwmon/70-hwmon.rules
@@ -0,0 +1 @@
+SUBSYSTEM=="hwmon", ACTION=="add", TAG+="systemd", ENV{SYSTEMD_WANTS}+="xyz.openbmc_project.Hwmon@%E{OF_FULLNAME}.service"
diff --git a/common/recipes-phosphor/sensors/phosphor-hwmon/xyz.openbmc_project.Hwmon@.service b/common/recipes-phosphor/sensors/phosphor-hwmon/xyz.openbmc_project.Hwmon@.service
new file mode 100644
index 0000000..fcfada6
--- /dev/null
+++ b/common/recipes-phosphor/sensors/phosphor-hwmon/xyz.openbmc_project.Hwmon@.service
@@ -0,0 +1,8 @@
+[Unit]
+Description=Phosphor Hwmon Poller
+ConditionFileNotEmpty=/etc/default/obmc/hwmon/%I.conf
+
+[Service]
+Restart=always
+ExecStart={sbindir}/phosphor-hwmon-readd -o %f
+EnvironmentFile=/etc/default/obmc/hwmon/%I.conf