Targets and services to check for pgood on bmc reset
Once enabled these targets and services will be run after
a BMC reboot to check if pgood is on and if so, to create
a file which will be used by other power on services
to know whether they need to run or not.
Change-Id: Id2e75f9bce20f362d2f57a79e91ece1eaf7d7c45
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
diff --git a/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-pgood-check@.service b/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-pgood-check@.service
new file mode 100644
index 0000000..b009537
--- /dev/null
+++ b/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-pgood-check@.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Check Chassis%i pgood on reset
+Wants=mapper-wait@-org-openbmc-control-power%i.service
+After=mapper-wait@-org-openbmc-control-power%i.service
+Wants=obmc-power-reset-on@%i.target
+Before=obmc-power-reset-on@%i.target
+Conflicts=obmc-power-chassis-off@%i.target
+
+[Service]
+RemainAfterExit=no
+Type=oneshot
+ExecStart=/bin/sh -c "busctl get-property `mapper get-service /org/openbmc/control/power%i` /org/openbmc/control/power%i org.openbmc.control.Power pgood | sed 's/i\s*[1]/on/' | grep on"
+
+
+[Install]
+WantedBy=obmc-chassis-reset@%i.target
diff --git a/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-set-power-on@.service b/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-set-power-on@.service
new file mode 100644
index 0000000..4d58d61
--- /dev/null
+++ b/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-set-power-on@.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Create file to indicate chassis%i pgood is on
+After=obmc-power-reset-on@%i.target
+Requires=obmc-power-reset-on@%i.target
+After=op-reset-pgood-check@%i.service
+Requires=op-reset-pgood-check@%i.service
+Conflicts=obmc-power-chassis-off@%i.target
+
+[Service]
+RemainAfterExit=no
+Type=oneshot
+ExecStart=/bin/sh -c "mkdir -p /run/openbmc/ && touch /run/openbmc/chassis@%i-on"
+
+
+[Install]
+WantedBy=obmc-chassis-reset@%i.target