bmc-reset: add service to launch new host recovery

Tested:
- Verified it does not run if chassis power is off
- Verified it runs but does nothing when chassis power is on but
  BootProgress is Undefined
- Verified it logged error and started recovery when chassis power was
  on and BootProgress was not Undefined

Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I191a318e637eaee2201aabcef59bf698de860707
diff --git a/service_files/meson.build b/service_files/meson.build
index c7a380a..649bd69 100644
--- a/service_files/meson.build
+++ b/service_files/meson.build
@@ -3,6 +3,7 @@
     'phosphor-discover-system-state@.service',
     'phosphor-reboot-host@.service',
     'phosphor-reset-host-reboot-attempts@.service',
+    'phosphor-reset-host-recovery@.service',
     'phosphor-reset-host-running@.service',
     'phosphor-reset-sensor-states@.service',
     'xyz.openbmc_project.State.BMC.service',
diff --git a/service_files/phosphor-reset-host-recovery@.service b/service_files/phosphor-reset-host-recovery@.service
new file mode 100644
index 0000000..cec36fe
--- /dev/null
+++ b/service_files/phosphor-reset-host-recovery@.service
@@ -0,0 +1,20 @@
+[Unit]
+Description=Recover host%i after bmc reboot
+After=obmc-host-reset@%i.target
+Wants=obmc-host-reset-running@%i.target
+After=obmc-host-reset-running@%i.target
+Wants=mapper-wait@-xyz-openbmc_project-state-host%i.service
+After=mapper-wait@-xyz-openbmc_project-state-host%i.service
+ConditionPathExists=/run/openbmc/chassis@%i-on
+ConditionPathExists=!/run/openbmc/host@%i-on
+Conflicts=obmc-chassis-poweroff@%i.target
+
+[Service]
+Restart=no
+Type=simple
+RemainAfterExit=yes
+ExecStart=/usr/bin/phosphor-host-reset-recovery
+
+
+[Install]
+WantedBy=obmc-chassis-poweron@%i.target