Add precondition checks on psu sensor service

This will prevent the psu sensor from restarting when powercycle is
happening.

Tested:
before the change:

Apr 02 14:33:23 dddhd28-nfd01.prod.google.com tray_powercycle.sh[8370]: Terminated
Apr 02 14:33:23 dddhd28-nfd01.prod.google.com tray_powercycle.sh[8370]: This service has been killed...
Apr 02 14:33:23 dddhd28-nfd01.prod.google.com tray_powercycle.sh[8370]: Stopping psusensor_monitor

Apr 02 14:34:54 dddhd28-nfd01.prod.google.com systemd[1]: chassis-system-reset.service: State 'stop-sigterm' timed out. Killing.
Apr 02 14:34:54 dddhd28-nfd01.prod.google.com systemd[1]: chassis-system-reset.service: Killing process 8370 (tray_powercycle) with signal SIGKILL.
Apr 02 14:34:54 dddhd28-nfd01.prod.google.com systemd[1]: chassis-system-reset.service: Killing process 8533 (sleep) with signal SIGKILL.
Apr 02 14:34:54 dddhd28-nfd01.prod.google.com systemd[1]: chassis-system-reset.service: Main process exited, code=killed, status=9/KILL
Apr 02 14:34:54 dddhd28-nfd01.prod.google.com systemd[1]: chassis-system-reset.service: Failed with result 'timeout'.
Apr 02 14:34:54 dddhd28-nfd01.prod.google.com systemd[1]: Stopped System unit to hard reset or system reset chassis.

after the change:

Apr 02 14:36:19 dddgy20-nfd01.prod.google.com tray_powercycle.sh[5385]: Stopping psusensor_monitor
Apr 02 14:36:19 dddgy20-nfd01.prod.google.com tray_powercycle.sh[5385]: Stop msvfud
Apr 02 14:36:19 dddgy20-nfd01.prod.google.com tray_powercycle.sh[5392]: {"Staged State":"UPDATED"}
Apr 02 14:36:19 dddgy20-nfd01.prod.google.com tray_powercycle.sh[5385]: fake bios update start

Apr 02 14:36:40 dddgy20-nfd01.prod.google.com systemd[1]: PSU Sensor was skipped because of an unmet condition check (ConditionPathExists=!/run/powercycle_ongoing).

Apr 02 14:41:19 dddgy20-nfd01.prod.google.com tray_powercycle.sh[5385]: powercycle happened!

https://fusion2.corp.google.com/2997dddd-e925-331d-a89b-1161f483a6e2

Google-Bug-Id: 332538728
Change-Id: I994d9d40d2ac143400252d46c80f2845febe8750
Signed-off-by: Yuxiao Zhang <yuxiaozhang@google.com>
(cherry picked from commit d44eed0dfebe6cb01bf85c1238e8c2d5b475ba84)
diff --git a/recipes-phosphor/sensors/dbus-sensors/50-gbmc-override.conf b/recipes-phosphor/sensors/dbus-sensors/50-gbmc-override.conf
new file mode 100644
index 0000000..2995e3f
--- /dev/null
+++ b/recipes-phosphor/sensors/dbus-sensors/50-gbmc-override.conf
@@ -0,0 +1,2 @@
+[Unit]
+ConditionPathExists=!/run/powercycle_ongoing
diff --git a/recipes-phosphor/sensors/dbus-sensors_%.bbappend b/recipes-phosphor/sensors/dbus-sensors_%.bbappend
index 4481782..63f7b04 100644
--- a/recipes-phosphor/sensors/dbus-sensors_%.bbappend
+++ b/recipes-phosphor/sensors/dbus-sensors_%.bbappend
@@ -1,6 +1,7 @@
 FILESEXTRAPATHS:prepend:gbmc := "${THISDIR}/${PN}:"
 
 SRC_URI:append:gbmc = " \
+  file://50-gbmc-override.conf \
   file://0002-psusensor-attempt-to-re-open-hwmon-files-if-reading-.patch \
   file://0003-gpiosensor-a-dedicated-daemon-to-report-gpio-status-.patch \
   file://0004-Feature-Add-association-interfaces-to-a-target-EM.patch \
@@ -128,3 +129,13 @@
 PACKAGECONFIG[redfishsensor] = "-Dredfish=enabled, -Dredfish=disabled"
 SYSTEMD_SERVICE:${PN} += "${@bb.utils.contains('PACKAGECONFIG', \
   'redfishsensor', 'xyz.openbmc_project.redfishsensor.service', '', d)}"
+
+FILES:${PN}:append:gbmc = " \
+    ${systemd_system_unitdir}/xyz.openbmc_project.psusensor.service.d/50-gbmc-override.conf \
+"
+
+do_install:append:gbmc() {
+    install -d -m0644 ${D}${systemd_system_unitdir}/xyz.openbmc_project.psusensor.service.d/
+    install -m0644 ${WORKDIR}/50-gbmc-override.conf \
+      ${D}${systemd_system_unitdir}/xyz.openbmc_project.psusensor.service.d/
+}