[03/17] meta-isar: deploy-image: Change reboot logic

Message ID 6e97e882f080e09a9f7d777cc84e9cd089d92d11.1719927511.git.jan.kiszka@siemens.com
State Accepted, archived
Headers show
Series Reworks, fixes and unattended mode for image installer | expand

Commit Message

Jan Kiszka July 2, 2024, 1:38 p.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

Pull the reboot out of the script. This allows for cleaner integration
with different calling environment, may they be a systemd unit, an
initramfs script or simply a shell for testing purposes.

And if the script exits with an error, wait a minute before rebooting
the system, rather than just trying to re-execute it. This permits to
inspect potential error as well.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 .../recipes-installer/deploy-image/files/deploy-image-wic.sh    | 2 +-
 .../recipes-installer/deploy-image/files/install.override.conf  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Patch

diff --git a/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh
index 8043aff1..12c1eea2 100644
--- a/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh
+++ b/meta-isar/recipes-installer/deploy-image/files/deploy-image-wic.sh
@@ -105,4 +105,4 @@  fi
 umount "$installdata"
 sync
 dialog --title "Reboot" --msgbox "Installation is successful. System will be rebooted. Please remove the USB stick." 7 60
-reboot
+exit 0
diff --git a/meta-isar/recipes-installer/deploy-image/files/install.override.conf b/meta-isar/recipes-installer/deploy-image/files/install.override.conf
index 73874caa..357d8662 100644
--- a/meta-isar/recipes-installer/deploy-image/files/install.override.conf
+++ b/meta-isar/recipes-installer/deploy-image/files/install.override.conf
@@ -1,5 +1,5 @@ 
 [Service]
 ExecStart=
-ExecStart=/usr/bin/deploy-image-wic.sh
+ExecStart=/bin/sh -c "deploy-image-wic.sh || (echo 'Rebooting in 60 s'; sleep 60); reboot"
 StandardInput=tty
 StandardOutput=tty