Combined services to create chassis-running service

Took the contents of op-reset-pgood-check and
op-reset-set-power-on and combined them to create
the new service op-reset-chassis-running.

Resolves openbmc/openbmc#1337

Change-Id: I6cdb93fcf9f7e701703482ef3dcb8b23ef75cf93
Signed-off-by: Josh D. King <jdking@us.ibm.com>
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
index 7c55e11..f2a7103 100644
--- 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
@@ -1,9 +1,10 @@
 [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
+Requires=op-reset-chassis-running@%i.service
+After=op-reset-chassis-running@%i.service
 After=obmc-power-reset-on@%i.target
 Requires=obmc-power-reset-on@%i.target
+ConditionPathExists=/run/openbmc/chassis@%i-on
 
 [Service]
 RemainAfterExit=no
diff --git a/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-chassis-running@.service b/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-chassis-running@.service
new file mode 100644
index 0000000..381f89d
--- /dev/null
+++ b/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-chassis-running@.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Check Chassis%i pgood and create a file to indicate it
+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-chassis-poweroff@%i.target
+
+[Service]
+RemainAfterExit=no
+Type=oneshot
+ExecStart=/bin/sh -c "if [ $(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 | wc -l) != 0 ]; then mkdir -p /run/openbmc/ && touch /run/openbmc/chassis@%i-on; fi"
+
+[Install]
+WantedBy=obmc-chassis-powerreset@%i.target
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
deleted file mode 100644
index ea975ea..0000000
--- a/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-pgood-check@.service
+++ /dev/null
@@ -1,16 +0,0 @@
-[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-chassis-poweroff@%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-powerreset@%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
deleted file mode 100644
index cfc1eed..0000000
--- a/common/recipes-phosphor/chassis/obmc-op-control-power/op-reset-set-power-on@.service
+++ /dev/null
@@ -1,16 +0,0 @@
-[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-chassis-poweroff@%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-powerreset@%i.target