commit:     d61b95fa199284170990948b3f0e51e32a213262
Author:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 14 15:58:17 2021 +0000
Commit:     Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
CommitDate: Sun Mar 14 19:34:08 2021 +0000
URL:        https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=d61b95fa

initrd.scripts: Add is_userinteraction_allowed() function

Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>

 defaults/initrd.scripts | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 3be18b5..53cb633 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -648,6 +648,15 @@ is_true() {
        return 1
 }
 
+is_userinteraction_allowed() {
+       if [ -f "${GK_USERINTERACTION_DISABLED_STATEFILE}" ]
+       then
+               return 1
+       fi
+
+       return 0
+}
+
 # Function to create an ext2 fs on $aufs_dev, $aufs_dev_mnt mountpoint
 create_changefs() {
        local size
@@ -1012,15 +1021,19 @@ run_debug_shell() {
 }
 
 run_emergency_shell() {
-       echo
-       gksosreport
-       good_msg 'You might want to save "/run/initramfs/gksosreport.txt" to a 
USB stick or /boot'
-       good_msg 'after mounting them and attach it to a bug report.'
+       if is_userinteraction_allowed
+       then
+               echo
+               gksosreport
+               good_msg 'You might want to save 
"/run/initramfs/gksosreport.txt" to a USB stick or /boot'
+               good_msg 'after mounting them and attach it to a bug report.'
+       fi
+
        run_shell
 }
 
 run_shell() {
-       if [ -f "${GK_USERINTERACTION_DISABLED_STATEFILE}" ]
+       if ! is_userinteraction_allowed
        then
                bad_msg "gk.userinteraction.disabled is set; Spawning a shell 
is disabled!"
                return

Reply via email to