side-switch: add service to run side-switch function
The side switch check should occur on any host firmware boot so put in
the obmc-host-startmin@.target. Ensure this service does not run when
the BMC is reset while the host is at runtime. Do not want to ever cause
a power down of a running host.
Tested:
- Booted system with running firmware at priority 0 and verified a quick
return and successful boot.
- Booted system with running firmware at priority 1 and verified system
was powered off, bmc was rebooted to other image, and system auto
powered on up to operating system.
Signed-off-by: Andrew Geissler <geissonator@yahoo.com>
Change-Id: I5553ab6fb5ebd58734d1169663ea25ede7f37dd3
diff --git a/side-switch/meson.build b/side-switch/meson.build
index 64ac49e..b13e53c 100644
--- a/side-switch/meson.build
+++ b/side-switch/meson.build
@@ -13,3 +13,11 @@
install: true,
install_dir: get_option('bindir')
)
+
+systemd_system_unit_dir = dependency('systemd').get_variable(
+ pkgconfig: 'systemdsystemunitdir',
+ pkgconfig_define: ['prefix', get_option('prefix')])
+
+install_data(
+ 'phosphor-bmc-side-switch.service',
+ install_dir: systemd_system_unit_dir)
diff --git a/side-switch/phosphor-bmc-side-switch.service b/side-switch/phosphor-bmc-side-switch.service
new file mode 100644
index 0000000..a5a1fbe
--- /dev/null
+++ b/side-switch/phosphor-bmc-side-switch.service
@@ -0,0 +1,24 @@
+[Unit]
+Description=Check if flash side switch is needed
+Wants=obmc-host-start-pre@0.target
+Before=obmc-host-start-pre@0.target
+Wants=obmc-mapper.target
+After=obmc-mapper.target
+Wants=xyz.openbmc_project.Software.BMC.Updater.service
+After=xyz.openbmc_project.Software.BMC.Updater.service
+Wants=xyz.openbmc_project.State.BMC.service
+After=xyz.openbmc_project.State.BMC.service
+Wants=xyz.openbmc_project.State.Chassis.service
+After=xyz.openbmc_project.State.Chassis.service
+Wants=xyz.openbmc_project.Settings.service
+After=xyz.openbmc_project.Settings.service
+ConditionPathExists=!/run/openbmc/host@0-on
+
+[Service]
+Restart=no
+Type=oneshot
+RemainAfterExit=no
+ExecStart=/usr/bin/phosphor-bmc-side-switch
+
+[Install]
+WantedBy=obmc-host-startmin@0.target