Skip to content

Commit

Permalink
Make the emergency shell slightly fancy
Browse files Browse the repository at this point in the history
- Change the title text
- Colorize some shell messsages
- Reference the 'help' shortcut
  • Loading branch information
zdykstra committed Mar 5, 2022
1 parent 5a5ab0b commit 8b1aade
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion contrib/luks-unlock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ while true; do
-p "Continuing in %0.2d seconds" ; then
continue
else
emergency_shell "Unable to unlock LUKS partition"
emergency_shell "unable to unlock LUKS partition"
fi
fi
done
13 changes: 8 additions & 5 deletions zfsbootmenu/lib/zfsbootmenu-core.sh
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ kexec_kernel() {
tput clear

if ! mnt=$( mount_zfs "${fs}" ); then
emergency_shell "unable to mount ${fs}"
emergency_shell "unable to mount $( colorize cyan "${fs}" )"
return 1
fi

Expand Down Expand Up @@ -1770,16 +1770,19 @@ zfs_chroot() {
# returns: nothing

emergency_shell() {
local message skip mp fs
message=${1:-unknown reason}
local skip mp fs

tput clear
tput cnorm
stty echo

echo -n "Launching emergency shell: "
echo -e "${message}\n"
cat <<-EOF
$( 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
/bin/bash -i

Expand Down
6 changes: 3 additions & 3 deletions zfsbootmenu/libexec/zfsbootmenu-init
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ if [ "${menu_timeout}" -ge 0 ] && [ -n "${BOOTFS}" ]; then
# Clear screen before a possible password prompt
tput clear
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
# Automatically select a kernel and boot it
kexec_kernel "$( select_kernel "${BOOTFS}" )"
Expand All @@ -221,13 +221,13 @@ fi
# If the lock file is present, drop to a recovery shell to avoid
# stealing control back from an SSH session
if [ -e "${BASE}/active" ] ; then
emergency_shell "type 'exit' to return to ZFSBootMenu"
emergency_shell "an active instance is already running"
fi

while true; do
if [ -x /bin/zfsbootmenu ]; then
/bin/zfsbootmenu
fi

emergency_shell "type 'exit' to return to ZFSBootMenu"
emergency_shell
done

0 comments on commit 8b1aade

Please sign in to comment.