aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Deutschmann <whissi@gentoo.org>2020-07-16 20:22:57 +0200
committerThomas Deutschmann <whissi@gentoo.org>2020-07-16 20:34:28 +0200
commit1a68a5349bb423ddff5ec56ea733631621eba862 (patch)
tree0078dd45ddd5a0fdc871b147ae93443b5c12814e
parentgen_initramfs.sh: create_initramfs(): Call set_initramfs_compression_method()... (diff)
downloadgenkernel-1a68a5349bb423ddff5ec56ea733631621eba862.tar.gz
genkernel-1a68a5349bb423ddff5ec56ea733631621eba862.tar.bz2
genkernel-1a68a5349bb423ddff5ec56ea733631621eba862.zip
linuxrc: Add gk.userinteraction.disabled
When this option is set and enabled, genkernel initramfs will not prompt on errors, i.e. this will disable any user interaction, e.g. for a kiosk system. Bug: https://bugs.gentoo.org/730966 Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
-rw-r--r--defaults/initrd.defaults1
-rw-r--r--defaults/initrd.scripts52
-rw-r--r--defaults/linuxrc8
-rw-r--r--doc/genkernel.8.txt8
4 files changed, 69 insertions, 0 deletions
diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index 15326dd2..79d7322c 100644
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -96,6 +96,7 @@ GK_SSHD_LOCKFILE='/tmp/remote-rescueshell.lock'
GK_SSHD_PIDFILE='/var/run/dropbear.pid'
GK_SSHD_PORT=22
GK_SSHD_WAIT=
+GK_USERINTERACTION_DISABLED_STATEFILE='/tmp/user-interaction.disabled'
CRYPT_ENV_FILE='/etc/CRYPT_ENV.conf'
CRYPT_KEYFILE_ROOT='/tmp/root.key'
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index d5378b7b..6dc588f7 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -959,6 +959,12 @@ run() {
}
run_shell() {
+ if [ -f "${GK_USERINTERACTION_DISABLED_STATEFILE}" ]
+ then
+ bad_msg "gk.userinteraction.disabled is set; Spawning a shell is disabled!"
+ return
+ fi
+
[ -x /bin/sh ] && SH=/bin/sh || SH=/bin/ash
run touch "${GK_SHELL_LOCKFILE}"
@@ -1114,6 +1120,15 @@ warn_msg() {
[ "$2" != '1' ] && printf "%b\n" "${WARN}**${NORMAL}${BOLD} ${msg_string} ${NORMAL}"
}
+warn_msg_n() {
+ local msg_string=${1}
+ msg_string="${msg_string:-...}"
+
+ log_msg "[**] ${msg_string}"
+
+ [ "$2" != '1' ] && printf "%b" "${WARN}**${NORMAL}${BOLD} ${msg_string}"
+}
+
write_env_file() {
local env_file=${1}
shift
@@ -1233,6 +1248,43 @@ prompt_user() {
[ -n "${3}" ] && local explnt=" or : ${3}" || local explnt="."
bad_msg "Could not find the ${2} in ${oldvalue}${explnt}"
+
+ if [ -f "${GK_USERINTERACTION_DISABLED_STATEFILE}" ]
+ then
+ bad_msg "gk.userinteraction.disabled is set; No user interaction allowed!"
+
+ wait_sshd
+
+ if [ -f "${GK_SSHD_LOCKFILE}" ]
+ then
+ warn_msg "The lockfile at '${GK_SSHD_LOCKFILE}' exists."
+ warn_msg "The boot process will be paused until the lock is removed."
+ while true
+ do
+ if [ -f "${GK_SSHD_LOCKFILE}" ]
+ then
+ sleep 1
+ else
+ break
+ fi
+ done
+ fi
+
+ local timeout=${GK_PROMPT_TIMEOUT}
+ [ ${timeout} -eq 0 ] && timeout=10
+
+ warn_msg_n "System will automatically reboot in ${timeout} seconds ..."
+ while [ ${timeout} -gt 0 ]
+ do
+ let timeout=${timeout}-1
+ sleep 1
+ printf "."
+ done
+ echo
+
+ reboot -f
+ fi
+
bad_msg "Please specify another value or:"
bad_msg "- press Enter for the same"
bad_msg '- type "shell" for a shell'
diff --git a/defaults/linuxrc b/defaults/linuxrc
index 682f6470..5354d09b 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -356,6 +356,14 @@ do
fi
unset tmp_wait
;;
+ gk.userinteraction.disabled=*)
+ tmp_disabled=${x#*=}
+ if is_true "${tmp_disabled}"
+ then
+ touch "${GK_USERINTERACTION_DISABLED_STATEFILE}"
+ fi
+ unset tmp_disabled
+ ;;
gk.prompt.timeout=*)
tmp_timeout=${x#*=}
if is_int "${tmp_timeout}"
diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
index 5b15a021..f84892c4 100644
--- a/doc/genkernel.8.txt
+++ b/doc/genkernel.8.txt
@@ -835,6 +835,14 @@ genkernel's initramfs will only mount root filesystem by default. If you
want to store the log file in '/var/log/genkernel-boot.log' for example
make sure that this mountpoint is accessible, see *initramfs.mounts*.
+*gk.userinteraction.disabled*=<...>::
+By default, genkernel will prompt on errors. In case this is not wanted
+or desired, e.g. for a kiosk system, this boolean option will disable
+any prompting, including the rescue shell.
+
+NOTE: Because no user interaction is possible when this option is set,
+system will automatically reboot on error after a timeout.
+
*noload*=<...>::
List of modules to skip loading.
Separate using commas or spaces.