Send HUP signal to mboxd on power off

mboxd needs to receive a HUP signal to reset it
in between boots, so this will do that on a power
off so it will be ready for the next boot.

This adds about 25s to the power off sequence.

Change-Id: Icaf86de0c1fda297e74229e5ab0b182dfba96456
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/common/recipes-phosphor/mboxd/mboxd.bb b/common/recipes-phosphor/mboxd/mboxd.bb
index 803c1b4..8349bb6 100644
--- a/common/recipes-phosphor/mboxd/mboxd.bb
+++ b/common/recipes-phosphor/mboxd/mboxd.bb
@@ -29,3 +29,12 @@
     install -d ${D}/lib/udev/rules.d
     install -m 0644 ${WORKDIR}/99-aspeed-mbox.rules ${D}/lib/udev/rules.d
 }
+
+TMPL = "mboxd-reload@.service"
+TGTFMT = "obmc-chassis-stop@{0}.target"
+INSTFMT = "mboxd-reload@{0}.service"
+FMT = "../${TMPL}:${TGTFMT}.wants/${INSTFMT}"
+
+SYSTEMD_SERVICE_${PN} += "mboxd.service"
+SYSTEMD_SERVICE_${PN} += "mboxd-reload@.service"
+SYSTEMD_LINK_${PN} += "${@compose_list(d, 'FMT', 'OBMC_CHASSIS_INSTANCES')}"
diff --git a/common/recipes-phosphor/mboxd/mboxd/mboxd-reload@.service b/common/recipes-phosphor/mboxd/mboxd/mboxd-reload@.service
new file mode 100644
index 0000000..1018224
--- /dev/null
+++ b/common/recipes-phosphor/mboxd/mboxd/mboxd-reload@.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Reload mboxd after power off
+Wants=op-wait-power-off@%i.service
+After=op-wait-power-off@%i.service
+Conflicts=obmc-chassis-start@%i.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/bin/killall -HUP mboxd
+
+[Install]
+WantedBy=obmc-chassis-stop@%i.target