transition: ensure only run once per power on/off
Some situations have arisen where a user requests a power off or on when
the system is already in that state. That results in these services
re-running and setting the state to transition even though the system is
actually off or on already.
The solution is to ensure these services only run once and do not stop
until a Conflicts occurs to stop it.
Tested:
- Verified service only runs once now even if started multiple times
- Verified when conflicting target runs that you can start service again
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I2aa866057fca9c1743385f0d5f3beff5899e4c15
diff --git a/service_files/phosphor-set-host-transition-to-off@.service b/service_files/phosphor-set-host-transition-to-off@.service
index 0e0a594..a1bb01f 100644
--- a/service_files/phosphor-set-host-transition-to-off@.service
+++ b/service_files/phosphor-set-host-transition-to-off@.service
@@ -4,10 +4,12 @@
After=mapper-wait@-xyz-openbmc_project-state-host%i.service
Wants=obmc-host-stop-pre@%i.target
Before=obmc-host-stop-pre@%i.target
+Conflicts=obmc-host-startmin@%i.target
[Service]
Restart=no
Type=oneshot
+RemainAfterExit=yes
ExecStart=/bin/sh -c "busctl set-property `mapper get-service /xyz/openbmc_project/state/host%i` /xyz/openbmc_project/state/host%i xyz.openbmc_project.State.Host CurrentHostState s xyz.openbmc_project.State.Host.HostState.TransitioningToOff"
[Install]