From c476cca52d33766e706204ca0f961947d8195f2a Mon Sep 17 00:00:00 2001 From: Michael Prokop <mprokop@sipwise.com> Date: Thu, 20 Jul 2023 19:05:47 +0200 Subject: [PATCH] MT#57453 Use tty1 for stdin when running under grml-autoconfig service Recent Grml ISOs, including our Grml-Sipwise ISO (v2023-06-01), include grml-autoconfig v0.20.3 which execute the grml-autoconfig service under `StandardInput=null`. This is necessary to not conflict with tty usage, like used with serial console. See https://github.com/grml/grml-autoconfig/commit/1e268ffe4f787e0fbe91b77792d6662d009e0a31 Now that we run with /dev/null for stdin, we can't interact with the user, so let's try to detect when running from within grml-autoconfig's systemd unit, and if so assume that we're executing on /dev/tty1 and use/reopen that for stdin. Change-Id: Id55283c7f862487a6ef8acb8ab01f67a05bd8dd7 (cherry picked from commit 561303359e463de11ea460aedfa02894785e1f3a) --- templates/scripts/includes/deployment.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/templates/scripts/includes/deployment.sh b/templates/scripts/includes/deployment.sh index 83fb20f..f59dcfe 100755 --- a/templates/scripts/includes/deployment.sh +++ b/templates/scripts/includes/deployment.sh @@ -1360,6 +1360,22 @@ INSTALL_LOG='/tmp/deployment-installer-debug.log' exec > >(tee -a $INSTALL_LOG ) exec 2> >(tee -a $INSTALL_LOG >&2) +# ensure we can interact with stdin +grml_autoconfig_active=false +case "$(systemctl is-active grml-autoconfig)" in + active|activating) + grml_autoconfig_active=true + ;; +esac + +if "${grml_autoconfig_active}" ; then + if systemctl cat grml-autoconfig.service | grep -q StandardInput=null ; then + echo "Looks like we're running under systemd with /dev/null for stdin." + echo "Re-executing with usage of /dev/tty1 for stdin" + exec < /dev/tty1 + fi +fi + # set version to git commit ID SCRIPT_VERSION="%SCRIPT_VERSION%"