Add optional reboot on BMC Quiesced

Add a systemd oneshot service (phosphor-bmc-quiesce-reboot.service)
that reboots the BMC. When linked into
obmc-bmc-service-quiesce@0.target.wants, the BMC will reboot upon
entering the BMC Quiesced target.

This change introduces a Meson feature option
"auto-reboot-on-bmc-quiesce" (disabled by default). When enabled, the
build installs a symlink from obmc-bmc-service-quiesce@0.target.wants
to phosphor-bmc-quiesce-reboot.service.

Motivation:
When critical services fail and the BMC enters Quiesced, a full BMC
reboot is often the cleanest recovery path. Making this policy
configurable allows platforms to automatically reboot on Quiesced.

Change-Id: I6c945dd1174723a26d4942b07a8e896131edc993
Signed-off-by: Eric Yang <eric.yang.wiwynn@gmail.com>
diff --git a/meson.options b/meson.options
index f7a3efc..f24d068 100644
--- a/meson.options
+++ b/meson.options
@@ -181,3 +181,10 @@
     value: true,
     description: 'run APR when BMC has been rebooted due to software request',
 )
+
+option(
+    'auto-reboot-on-bmc-quiesce',
+    type: 'feature',
+    value: 'enabled',
+    description: 'Link phosphor-bmc-quiesce-reboot.service into obmc-bmc-service-quiesce@0.target.wants to automatically reboot when BMC enters Quiesced',
+)
diff --git a/service_files/meson.build b/service_files/meson.build
index 5d53464..f4b3bcb 100644
--- a/service_files/meson.build
+++ b/service_files/meson.build
@@ -23,6 +23,7 @@
     'phosphor-create-chassis-poweron-log@.service',
     'phosphor-set-chassis-transition-to-on@.service',
     'phosphor-set-chassis-transition-to-off@.service',
+    'phosphor-bmc-quiesce-reboot.service',
 ]
 
 fs = import('fs')
diff --git a/service_files/phosphor-bmc-quiesce-reboot.service b/service_files/phosphor-bmc-quiesce-reboot.service
new file mode 100644
index 0000000..3c50bd1
--- /dev/null
+++ b/service_files/phosphor-bmc-quiesce-reboot.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Reboot BMC after entering BMC Quiesced
+DefaultDependencies=no
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/systemctl reboot
diff --git a/target_files/meson.build b/target_files/meson.build
index fda4503..a9f9d09 100644
--- a/target_files/meson.build
+++ b/target_files/meson.build
@@ -44,3 +44,12 @@
 foreach u : unit_files
     fs.copyfile(u, install: true, install_dir: systemd_system_unit_dir)
 endforeach
+
+if get_option('auto-reboot-on-bmc-quiesce').enabled()
+    wants_dir = systemd_system_unit_dir / 'obmc-bmc-service-quiesce@0.target.wants'
+    install_symlink(
+        'phosphor-bmc-quiesce-reboot.service',
+        install_dir: wants_dir,
+        pointing_to: '../phosphor-bmc-quiesce-reboot.service',
+    )
+endif