Skip to content

Commit 8b1aade

Browse files
committed
Make the emergency shell slightly fancy
- Change the title text - Colorize some shell messsages - Reference the 'help' shortcut
1 parent 5a5ab0b commit 8b1aade

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

contrib/luks-unlock.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ while true; do
9898
-p "Continuing in %0.2d seconds" ; then
9999
continue
100100
else
101-
emergency_shell "Unable to unlock LUKS partition"
101+
emergency_shell "unable to unlock LUKS partition"
102102
fi
103103
fi
104104
done

zfsbootmenu/lib/zfsbootmenu-core.sh

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ kexec_kernel() {
302302
tput clear
303303

304304
if ! mnt=$( mount_zfs "${fs}" ); then
305-
emergency_shell "unable to mount ${fs}"
305+
emergency_shell "unable to mount $( colorize cyan "${fs}" )"
306306
return 1
307307
fi
308308

@@ -1770,16 +1770,19 @@ zfs_chroot() {
17701770
# returns: nothing
17711771

17721772
emergency_shell() {
1773-
local message skip mp fs
1774-
message=${1:-unknown reason}
1773+
local skip mp fs
17751774

17761775
tput clear
17771776
tput cnorm
17781777
stty echo
17791778

1780-
echo -n "Launching emergency shell: "
1781-
echo -e "${message}\n"
1779+
cat <<-EOF
1780+
$( colorize green "emergency shell")${1:+: $1}
1781+
1782+
type '$(colorize red "help")' for online documentation
1783+
type '$( colorize red "exit")' to return to ZFSBootMenu
17821784
1785+
EOF
17831786
# -i (interactive) mode will source $HOME/.bashrc
17841787
/bin/bash -i
17851788

zfsbootmenu/libexec/zfsbootmenu-init

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ if [ "${menu_timeout}" -ge 0 ] && [ -n "${BOOTFS}" ]; then
209209
# Clear screen before a possible password prompt
210210
tput clear
211211
if ! NO_CACHE=1 load_key "${BOOTFS}"; then
212-
emergency_shell "unable to load key for ${BOOTFS}; type 'exit' to continue"
212+
emergency_shell "unable to load key for $( colorize cyan "${BOOTFS}" )"
213213
elif find_be_kernels "${BOOTFS}" && [ ! -e "${BASE}/active" ]; then
214214
# Automatically select a kernel and boot it
215215
kexec_kernel "$( select_kernel "${BOOTFS}" )"
@@ -221,13 +221,13 @@ fi
221221
# If the lock file is present, drop to a recovery shell to avoid
222222
# stealing control back from an SSH session
223223
if [ -e "${BASE}/active" ] ; then
224-
emergency_shell "type 'exit' to return to ZFSBootMenu"
224+
emergency_shell "an active instance is already running"
225225
fi
226226

227227
while true; do
228228
if [ -x /bin/zfsbootmenu ]; then
229229
/bin/zfsbootmenu
230230
fi
231231

232-
emergency_shell "type 'exit' to return to ZFSBootMenu"
232+
emergency_shell
233233
done

0 commit comments

Comments
 (0)