Service for enabling/disabling host failure reboots

Wraps the auto_reboot host setting in a service so it
can be enabled or disabled by starting or stopping the
service.

Change-Id: Ib3e92f67eb833cd6e31e153b58a63edb6837ae2c
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/common/recipes-phosphor/chassis/obmc-host-failure-reboots.bb b/common/recipes-phosphor/chassis/obmc-host-failure-reboots.bb
new file mode 100644
index 0000000..e0f9b84
--- /dev/null
+++ b/common/recipes-phosphor/chassis/obmc-host-failure-reboots.bb
@@ -0,0 +1,9 @@
+SUMMARY = "Enables reboots on host failures"
+DESCRIPTION = "Manages the settings entry that controls reboots \
+on host failures"
+PR = "r1"
+
+inherit obmc-phosphor-systemd
+inherit obmc-phosphor-license
+
+SYSTEMD_SERVICE_${PN} += "host-failure-reboots.service"
diff --git a/common/recipes-phosphor/chassis/obmc-host-failure-reboots/host-failure-reboots.service b/common/recipes-phosphor/chassis/obmc-host-failure-reboots/host-failure-reboots.service
new file mode 100644
index 0000000..81902ae
--- /dev/null
+++ b/common/recipes-phosphor/chassis/obmc-host-failure-reboots/host-failure-reboots.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Enable reboot on host failures
+Wants=mapper-wait@-org-openbmc-settings-host0.service
+After=mapper-wait@-org-openbmc-settings-host0.service
+
+[Service]
+ExecStart = /bin/sh -c "busctl set-property `mapper get-service /org/openbmc/settings/host0` /org/openbmc/settings/host0 org.openbmc.settings.Host auto_reboot s \"yes\""
+ExecStop = /bin/sh -c "busctl set-property `mapper get-service /org/openbmc/settings/host0` /org/openbmc/settings/host0 org.openbmc.settings.Host auto_reboot s \"no\""
+Type=oneshot
+RemainAfterExit=yes
+
+[Install]
+WantedBy={SYSTEMD_DEFAULT_TARGET}