Make the emergency shell slightly fancy

- Change the title text
- Colorize some shell messsages
- Reference the 'help' shortcut
This commit is contained in:
Zach Dykstra 2022-03-04 21:48:16 -06:00
parent 5a5ab0b4d4
commit 8b1aade829
3 changed files with 12 additions and 9 deletions

View File

@ -98,7 +98,7 @@ while true; do
-p "Continuing in %0.2d seconds" ; then -p "Continuing in %0.2d seconds" ; then
continue continue
else else
emergency_shell "Unable to unlock LUKS partition" emergency_shell "unable to unlock LUKS partition"
fi fi
fi fi
done done

View File

@ -302,7 +302,7 @@ kexec_kernel() {
tput clear tput clear
if ! mnt=$( mount_zfs "${fs}" ); then if ! mnt=$( mount_zfs "${fs}" ); then
emergency_shell "unable to mount ${fs}" emergency_shell "unable to mount $( colorize cyan "${fs}" )"
return 1 return 1
fi fi
@ -1770,16 +1770,19 @@ zfs_chroot() {
# returns: nothing # returns: nothing
emergency_shell() { emergency_shell() {
local message skip mp fs local skip mp fs
message=${1:-unknown reason}
tput clear tput clear
tput cnorm tput cnorm
stty echo stty echo
echo -n "Launching emergency shell: " cat <<-EOF
echo -e "${message}\n" $( colorize green "emergency shell")${1:+: $1}
type '$(colorize red "help")' for online documentation
type '$( colorize red "exit")' to return to ZFSBootMenu
EOF
# -i (interactive) mode will source $HOME/.bashrc # -i (interactive) mode will source $HOME/.bashrc
/bin/bash -i /bin/bash -i

View File

@ -209,7 +209,7 @@ if [ "${menu_timeout}" -ge 0 ] && [ -n "${BOOTFS}" ]; then
# Clear screen before a possible password prompt # Clear screen before a possible password prompt
tput clear tput clear
if ! NO_CACHE=1 load_key "${BOOTFS}"; then if ! NO_CACHE=1 load_key "${BOOTFS}"; then
emergency_shell "unable to load key for ${BOOTFS}; type 'exit' to continue" emergency_shell "unable to load key for $( colorize cyan "${BOOTFS}" )"
elif find_be_kernels "${BOOTFS}" && [ ! -e "${BASE}/active" ]; then elif find_be_kernels "${BOOTFS}" && [ ! -e "${BASE}/active" ]; then
# Automatically select a kernel and boot it # Automatically select a kernel and boot it
kexec_kernel "$( select_kernel "${BOOTFS}" )" kexec_kernel "$( select_kernel "${BOOTFS}" )"
@ -221,7 +221,7 @@ fi
# If the lock file is present, drop to a recovery shell to avoid # If the lock file is present, drop to a recovery shell to avoid
# stealing control back from an SSH session # stealing control back from an SSH session
if [ -e "${BASE}/active" ] ; then if [ -e "${BASE}/active" ] ; then
emergency_shell "type 'exit' to return to ZFSBootMenu" emergency_shell "an active instance is already running"
fi fi
while true; do while true; do
@ -229,5 +229,5 @@ while true; do
/bin/zfsbootmenu /bin/zfsbootmenu
fi fi
emergency_shell "type 'exit' to return to ZFSBootMenu" emergency_shell
done done