diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/99emergency-timeout/timeout.sh b/overlay.d/05core/usr/lib/dracut/modules.d/99emergency-timeout/emergency-shell.sh similarity index 59% rename from overlay.d/05core/usr/lib/dracut/modules.d/99emergency-timeout/timeout.sh rename to overlay.d/05core/usr/lib/dracut/modules.d/99emergency-timeout/emergency-shell.sh index 85fb3d761d..6af08e539f 100644 --- a/overlay.d/05core/usr/lib/dracut/modules.d/99emergency-timeout/timeout.sh +++ b/overlay.d/05core/usr/lib/dracut/modules.d/99emergency-timeout/emergency-shell.sh @@ -22,13 +22,7 @@ _wait_for_journalctl_to_stop() { done } -_prompt_for_timeout() { - local timeout=300 - local interval=15 - - if [[ -e /.emergency-shell-confirmed ]]; then - return - fi +_display_relevant_errors() { failed=$(systemctl --failed --no-legend --plain | cut -f 1 -d ' ') if [ -n "${failed}" ]; then # Something failed, suppress kernel logs so that it's more likely @@ -59,41 +53,9 @@ EOF journalctl -b --no-pager --no-hostname -u ${unit} -n 10 done fi - - # Regularly prompt with time remaining. This ensures the prompt doesn't - # get lost among kernel and systemd messages, and makes it clear what's - # going on if the user just connected a serial console. - while [[ $timeout > 0 ]]; do - local m=$(( $timeout / 60 )) - local s=$(( $timeout % 60 )) - local m_label="minutes" - if [[ $m = 1 ]]; then - m_label="minute" - fi - - if [[ $s != 0 ]]; then - echo -n -e "Press Enter for emergency shell or wait $m $m_label $s seconds for reboot. \r" - else - echo -n -e "Press Enter for emergency shell or wait $m $m_label for reboot. \r" - fi - - local anything - if read -t $interval anything; then - > /.emergency-shell-confirmed - return - fi - timeout=$(( $timeout - $interval )) - done - - echo -e "\nRebooting." - # This is not very nice, but since reboot.target likely conflicts with - # the existing goal target wrt the desired state of shutdown.target, - # there doesn't seem to be a better option. - systemctl reboot --force - exit 0 } # If we're invoked from a dracut breakpoint rather than # dracut-emergency.service, we won't have a controlling terminal and stdio # won't be connected to it. Explicitly read/write /dev/console. -_prompt_for_timeout < /dev/console > /dev/console +_display_relevant_errors < /dev/console > /dev/console diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/99emergency-timeout/module-setup.sh b/overlay.d/05core/usr/lib/dracut/modules.d/99emergency-timeout/module-setup.sh index 63907da412..58d8baeaa5 100755 --- a/overlay.d/05core/usr/lib/dracut/modules.d/99emergency-timeout/module-setup.sh +++ b/overlay.d/05core/usr/lib/dracut/modules.d/99emergency-timeout/module-setup.sh @@ -17,7 +17,7 @@ install() { cut \ date - inst_hook emergency 99 "${moddir}/timeout.sh" + inst_hook emergency 99 "${moddir}/emergency-shell.sh" inst_script "$moddir/ignition-virtio-dump-journal.sh" "/usr/bin/ignition-virtio-dump-journal" install_unit_wants ignition-virtio-dump-journal.service emergency.target