set_default_kernel: properly clear default when no kernel is specified

This commit is contained in:
Andrew J. Hesford 2022-12-18 16:47:19 -05:00
parent 7f929f1ad9
commit 8e6ca4a8da
1 changed files with 6 additions and 5 deletions

View File

@ -624,19 +624,20 @@ set_default_kernel() {
fi
zdebug "pool set to ${pool}"
# Strip /boot/ to list only the file
kernel="${2#/boot/}$"
zdebug "kernel set to ${kernel}"
# Make sure the pool is writable
set_rw_pool "${pool}" || return 1
CLEAR_SCREEN=1 load_key "${fs}"
# Strip /boot/ to list only the file
kernel="${2#/boot/}"
# Restore nonspecific default when no kernel specified
if [ -z "$kernel" ]; then
zdebug "clearing default kernel"
zfs inherit org.zfsbootmenu:kernel "${fs}" || return 1
else
zfs set org.zfsbootmenu:kernel="${kernel}" "${fs}" || return 1
zdebug "kernel set to ${kernel}"
zfs set org.zfsbootmenu:kernel="${kernel}$" "${fs}" || return 1
fi
return 0