Do not attempt to update EFI boot in containers.

Containers (at least many fo them) will bind-mount /sys which works for most
cases but it means that /sys will indicate EFI boot when it is, in fact, the
host system that has EFI boot.  To fix this we use systemd-detect-virt to see if
we're running in a container and if so we don't attempt to update EFI boot.
This commit is contained in:
Peter Ajamian 2021-08-08 21:57:45 +12:00
parent 6603d6cc6e
commit 2f40d60ec2

View File

@ -209,9 +209,8 @@ bin_check() {
local -a missing bins local -a missing bins
bins=( bins=(
rpm dnf awk column tee tput mkdir rpm dnf awk column tee tput mkdir cat arch sort uniq
cat arch sort uniq rmdir rm head rmdir rm head curl sha512sum mktemp systemd-detect-virt
curl sha512sum mktemp
) )
if [[ $update_efi ]]; then if [[ $update_efi ]]; then
bins+=(findmnt grub2-mkconfig efibootmgr grep mokutil lsblk) bins+=(findmnt grub2-mkconfig efibootmgr grep mokutil lsblk)
@ -852,7 +851,8 @@ efi_check () {
fi fi
# Now that we know /sys is reliable, use it to check if we are running on EFI or not # Now that we know /sys is reliable, use it to check if we are running on EFI or not
if [[ -d /sys/firmware/efi/ ]]; then if [[ -d /sys/firmware/efi/ ]] && ! systemd-detect-virt --quiet --container
then
declare -g update_efi declare -g update_efi
update_efi=true update_efi=true
fi fi