mirror of
https://github.com/rocky-linux/rocky-tools.git
synced 2024-11-26 06:56:25 +00:00
Automatically run EFI conversion steps
Before this commit the user was supposed to give the -e cmdline parameter to run the EFI conversion when necessary. But it was missing in the getopts parameter list, so it didn't work. Instead of fixing it, I opted to remove the -e parameter alltogether and automatically detect if the system is running on EFI or not. Because if the user should forget to give -e on an EFI system, it would result in an unbootable system without any bootmanager installed. Fixing this situation takes time and requires some sysadmin skills, so we should take steps to avoid this situation. Detecting if the system runs on EFI or not can reliably done by checking for /sys/firmware/efi/.
This commit is contained in:
parent
656ca6227e
commit
47c7ab35c0
@ -382,7 +382,6 @@ usage() {
|
|||||||
"Usage: ${0##*/} [OPTIONS]" \
|
"Usage: ${0##*/} [OPTIONS]" \
|
||||||
'' \
|
'' \
|
||||||
'Options:' \
|
'Options:' \
|
||||||
'-e Update EFI boot sector when done' \
|
|
||||||
'-h Display this help' \
|
'-h Display this help' \
|
||||||
'-r Convert to rocky' \
|
'-r Convert to rocky' \
|
||||||
'-V Verify switch' \
|
'-V Verify switch' \
|
||||||
@ -517,6 +516,21 @@ EOF
|
|||||||
dnf -y distro-sync || exit_message "Error during distro-sync."
|
dnf -y distro-sync || exit_message "Error during distro-sync."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if this system is running on EFI
|
||||||
|
# If yes, we'll need to run fix_efi() at the end of the conversion
|
||||||
|
efi_check () {
|
||||||
|
# Check if we have /sys mounted and it is looking sane
|
||||||
|
if ! [[ -d /sys/class/block ]]; then
|
||||||
|
exit_message "/sys is not accessible."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# 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
|
||||||
|
declare -g update_efi
|
||||||
|
update_efi=true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Called to update the EFI boot.
|
# Called to update the EFI boot.
|
||||||
fix_efi () (
|
fix_efi () (
|
||||||
grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg ||
|
grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg ||
|
||||||
@ -540,9 +554,6 @@ while getopts "hrVR" option; do
|
|||||||
V)
|
V)
|
||||||
verify_all_rpms=true
|
verify_all_rpms=true
|
||||||
;;
|
;;
|
||||||
e)
|
|
||||||
update_efi=true
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
printf '%s\n' "${errcolor}Invalid switch.$nocolor"
|
printf '%s\n' "${errcolor}Invalid switch.$nocolor"
|
||||||
usage
|
usage
|
||||||
@ -553,6 +564,7 @@ if (( ! noopts )); then
|
|||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
efi_check
|
||||||
bin_check
|
bin_check
|
||||||
|
|
||||||
if [[ $verify_all_rpms ]]; then
|
if [[ $verify_all_rpms ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user