host-state: make reboot count configurable via recipe

Make reset reboot count configurable via the already existing
boot-count-max-allowed option.

The default value is 3, that it's aligned with the current behavior.

Tested:

On romulus qemu, without modifying the recipe:

 - A call obmcutil poweron triggers the boot sequence the default number
   of times before quiescing.

 - The dbus property RetryAttempts is also set to the default value.

Modifying the recipe, and setting it to another value, e.g. 5

 - The boot sequence is triggered up to 5 times before quiescing.

 - The dbus property RetryAttemps is set to the correct value (in this
   case 5)

Also checked that the phosphor-reset-host-reboot-attempts.service has
the configured value in both scenarios.

Change-Id: I8f999271faa0f1708fcaf8321caffdb38f3d9f39
Signed-off-by: Roger G. Coscojuela <roger.gili-coscojuela@sipearl.com>
diff --git a/service_files/meson.build b/service_files/meson.build
index aeb4f38..5d53464 100644
--- a/service_files/meson.build
+++ b/service_files/meson.build
@@ -7,7 +7,6 @@
     'phosphor-reboot-host@.service',
     'phosphor-reset-chassis-on@.service',
     'phosphor-reset-chassis-running@.service',
-    'phosphor-reset-host-reboot-attempts@.service',
     'phosphor-reset-host-recovery@.service',
     'phosphor-reset-host-running@.service',
     'phosphor-reset-sensor-states@.service',
@@ -30,3 +29,14 @@
 foreach u : unit_files
     fs.copyfile(u, install: true, install_dir: systemd_system_unit_dir)
 endforeach
+
+
+configure_file(
+    input: 'phosphor-reset-host-reboot-attempts@.service.in',
+    output: 'phosphor-reset-host-reboot-attempts@.service',
+    install_dir: systemd_system_unit_dir,
+    install: true,
+    configuration: configuration_data(
+        {'BOOT_COUNT_MAX_ALLOWED': get_option('boot-count-max-allowed')},
+    ),
+)
diff --git a/service_files/phosphor-reset-host-reboot-attempts@.service b/service_files/phosphor-reset-host-reboot-attempts@.service.in
similarity index 94%
rename from service_files/phosphor-reset-host-reboot-attempts@.service
rename to service_files/phosphor-reset-host-reboot-attempts@.service.in
index 35de430..8a385d8 100644
--- a/service_files/phosphor-reset-host-reboot-attempts@.service
+++ b/service_files/phosphor-reset-host-reboot-attempts@.service.in
@@ -7,7 +7,7 @@
 [Service]
 Restart=no
 Type=oneshot
-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.Control.Boot.RebootAttempts AttemptsLeft u 3"
+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.Control.Boot.RebootAttempts AttemptsLeft u @BOOT_COUNT_MAX_ALLOWED@"
 
 [Install]
 WantedBy=obmc-host-start@%i.target