Add phosphor-fan-monitor init service

Updated the phosphor-fan-monitor service file to invoke the fan
monitoring application in 'monitor' mode (actively updating the
functional states of fans).
Created a phosphor-fan-monitor-init service to invoke the fan monitoring
application in 'init' mode where the fans are set to functional, such as
at poweron.

Resolves openbmc/openbmc#2187

Change-Id: If6d1763d69d69f55b7c69bd8b6496f6c9af70589
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan.bb b/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan.bb
index e70bd5b..79329b0 100644
--- a/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan.bb
+++ b/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan.bb
@@ -103,9 +103,14 @@
 INSTFMT_MONITOR = "phosphor-fan-monitor@{0}.service"
 FMT_MONITOR = "../${TMPL_MONITOR}:${FAN_CONTROL_TGT}.requires/${INSTFMT_MONITOR}"
 
+TMPL_MONITOR_INIT = "phosphor-fan-monitor-init@.service"
+INSTFMT_MONITOR_INIT = "phosphor-fan-monitor-init@{0}.service"
+FMT_MONITOR_INIT = "../${TMPL_MONITOR_INIT}:${POWERON_TGT}.requires/${INSTFMT_MONITOR_INIT}"
+
 FILES_${PN}-monitor = "${sbindir}/phosphor-fan-monitor"
-SYSTEMD_SERVICE_${PN}-monitor += "${TMPL_MONITOR}"
+SYSTEMD_SERVICE_${PN}-monitor += "${TMPL_MONITOR} ${TMPL_MONITOR_INIT}"
 SYSTEMD_LINK_${PN}-monitor += "${@compose_list(d, 'FMT_MONITOR', 'OBMC_CHASSIS_INSTANCES')}"
+SYSTEMD_LINK_${PN}-monitor += "${@compose_list(d, 'FMT_MONITOR_INIT', 'OBMC_CHASSIS_INSTANCES')}"
 
 # --------------------------------------
 # phosphor-cooling-type specific configuration
diff --git a/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan/phosphor-fan-monitor-init@.service b/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan/phosphor-fan-monitor-init@.service
new file mode 100644
index 0000000..a01acad
--- /dev/null
+++ b/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan/phosphor-fan-monitor-init@.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Phosphor Fan Monitor Initialization
+Wants=obmc-power-on@%i.target
+After=obmc-power-on@%i.target
+Conflicts=obmc-chassis-poweroff@%i.target
+
+[Service]
+Restart=on-failure
+ExecStart=/usr/bin/env phosphor-fan-monitor --init
+SyslogIdentifier=phosphor-fan-monitor
+
+[Install]
+RequiredBy=obmc-chassis-poweron@%i.target
diff --git a/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan/phosphor-fan-monitor@.service b/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan/phosphor-fan-monitor@.service
index 2392dcd..09f3494 100644
--- a/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan/phosphor-fan-monitor@.service
+++ b/meta-phosphor/common/recipes-phosphor/fans/phosphor-fan/phosphor-fan-monitor@.service
@@ -1,15 +1,11 @@
 [Unit]
 Description=Phosphor Fan Monitor Daemon
-Wants=phosphor-fan-control@%i.service
-Before=phosphor-fan-control@%i.service
 Conflicts=obmc-chassis-poweroff@%i.target
 
 [Service]
 Restart=on-failure
-ExecStart=/usr/bin/env phosphor-fan-monitor
+ExecStart=/usr/bin/env phosphor-fan-monitor --monitor
 SyslogIdentifier=phosphor-fan-monitor
-Type=notify
-NotifyAccess=all
 
 [Install]
 RequiredBy=obmc-fan-control-ready@%i.target