the deploy-image service was directly invoked the installer
script, which could result in the script running without a properly
configured TTY or missing TERM environment variable. This was observed
when bypassing agetty during service startup
now we launch the installer under agetty to ensure that it runs in a
fully initialized terminal environment. Since the service is now managed
by agetty, we ensure that the system reboots once the installation
completes (successfully or not) by adding a trap handler.
Signed-off-by: Kasturi Shekar <
kasturi...@siemens.com>
---
 .../deploy-image-service/files/install.override.conf |  2 +-
 .../deploy-image/files/usr/bin/deploy-image-wic.sh   | 12 ++++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/meta-isar/recipes-installer/deploy-image-service/files/install.override.conf b/meta-isar/recipes-installer/deploy-image-service/files/install.override.conf
index 357d8662..913efac5 100644
--- a/meta-isar/recipes-installer/deploy-image-service/files/install.override.conf
+++ b/meta-isar/recipes-installer/deploy-image-service/files/install.override.conf
@@ -1,5 +1,5 @@
 [Service]
 ExecStart=
-ExecStart=/bin/sh -c "deploy-image-wic.sh || (echo 'Rebooting in 60 s'; sleep 60); reboot"
+ExecStart=-/sbin/agetty -o --noclear -a root -l /usr/bin/deploy-image-wic.sh --keep-baud 115200,38400,9600 %I $TERM
 StandardInput=tty
 StandardOutput=tty
diff --git a/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh b/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
index 333762f1..7618a810 100755
--- a/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
+++ b/meta-isar/recipes-installer/deploy-image/files/usr/bin/deploy-image-wic.sh
@@ -3,6 +3,18 @@
 # Copyright (C) Siemens AG, 2024
 #
 # SPDX-License-Identifier: MIT
+trap reboot_on_exit EXIT
+
+reboot_on_exit() {
+    status=$?
+    if [ $status -eq 0 ]; then
+        echo "Installation completed successfully. Rebooting..."
+    else
+        echo "Installation failed. Rebooting in 60 seconds..."
+        sleep 60
+    fi
+    exec reboot
+}
 
 installdata=${INSTALL_DATA:-/install}
 
-- 
2.39.5