Automatically check for chassis power on BMC reboot

Run the obmc-chassis-reset@.target:
- Check if pgood is on
- If it is, create the file in /run/openbmc/chassis@%i-on and
- Run the systemctl command to start the chassis power on target

Resolves openbmc/openbmc#1094

Change-Id: I93f94fc1b75e35fd353387d0bed5569e07615171
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
diff --git a/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-chassis-on@.service b/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-chassis-on@.service
new file mode 100644
index 0000000..e41950d
--- /dev/null
+++ b/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-chassis-on@.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Start chassis%i on after BMC reset
+Requires=op-reset-set-power-on@%i.service
+After=op-reset-set-power-on@%i.service
+After=obmc-power-reset-on@%i.target
+Requires=obmc-power-reset-on@%i.target
+
+[Service]
+RemainAfterExit=no
+ExecStart=/bin/systemctl start obmc-power-chassis-on@%i.target
+
+
+[Install]
+WantedBy=obmc-chassis-reset@%i.target
diff --git a/common/recipes-phosphor/chassis/obmc-op-control-power/op-wait-power-off@.service b/common/recipes-phosphor/chassis/obmc-op-control-power/op-wait-power-off@.service
index 8c4d3d3..46e413e 100644
--- a/common/recipes-phosphor/chassis/obmc-op-control-power/op-wait-power-off@.service
+++ b/common/recipes-phosphor/chassis/obmc-op-control-power/op-wait-power-off@.service
@@ -11,6 +11,7 @@
 Type=oneshot
 RemainAfterExit=yes
 ExecStart={sbindir}/pgood_wait /org/openbmc/control/power%i off
+ExecStart=/bin/rm -f /run/openbmc/chassis@%i-on
 
 [Install]
 WantedBy=obmc-chassis-stop@%i.target