mirror of
https://github.com/rocky-linux/rocky-tools.git
synced 2024-11-25 14:41:25 +00:00
Add support for EFI
You can now pass the -e switch to update EFI boot settings at the end of the migration.
This commit is contained in:
parent
7aa8c84ce2
commit
800cf77a38
@ -91,9 +91,15 @@ bin_check() {
|
|||||||
exit_message "bash >= 4.0 is required for this script."
|
exit_message "bash >= 4.0 is required for this script."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local -a missing
|
local -a missing bins
|
||||||
for bin in rpm dnf awk column tee tput mkdir cat arch sort uniq rmdir rm \
|
bins=(
|
||||||
head; do
|
rpm dnf awk column tee tput mkdir
|
||||||
|
cat arch sort uniq rmdir rm head
|
||||||
|
)
|
||||||
|
if [[ $update_efi ]]; then
|
||||||
|
bins+=(findmnt grub2-mkconfig efibootmgr)
|
||||||
|
fi
|
||||||
|
for bin in "${bins[@]}"; do
|
||||||
if ! type "$bin" >/dev/null 2>&1; then
|
if ! type "$bin" >/dev/null 2>&1; then
|
||||||
missing+=("$bin")
|
missing+=("$bin")
|
||||||
fi
|
fi
|
||||||
@ -193,6 +199,15 @@ provides_pkg () (
|
|||||||
)
|
)
|
||||||
|
|
||||||
collect_system_info () {
|
collect_system_info () {
|
||||||
|
# Check the efi mount first, so we can bail before wasting time on all these
|
||||||
|
# other checks if it's not there.
|
||||||
|
if [[ $update_efi ]]; then
|
||||||
|
declare -g efi_mount
|
||||||
|
efi_mount=$(findmnt --mountpoint /boot/efi --output SOURCE \
|
||||||
|
--noheadings) ||
|
||||||
|
exit_message "Can't find EFI mount. No EFI boot detected."
|
||||||
|
fi
|
||||||
|
|
||||||
# Don't enable these module streams, even if they are enabled in the source
|
# Don't enable these module streams, even if they are enabled in the source
|
||||||
# distro.
|
# distro.
|
||||||
declare -g -a module_excludes
|
declare -g -a module_excludes
|
||||||
@ -359,16 +374,17 @@ collect_system_info () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
convert_info_dir=/root/convert
|
convert_info_dir=/root/convert
|
||||||
unset convert_to_rocky reinstall_all_rpms verify_all_rpms
|
unset convert_to_rocky reinstall_all_rpms verify_all_rpms update_efi
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
printf '%s\n' \
|
printf '%s\n' \
|
||||||
"Usage: ${0##*/} [OPTIONS]" \
|
"Usage: ${0##*/} [OPTIONS]" \
|
||||||
'' \
|
'' \
|
||||||
'Options:' \
|
'Options:' \
|
||||||
'-h displays this help' \
|
'-e Update EFI boot sector when done' \
|
||||||
'-r Converts to rocky' \
|
'-h Display this help' \
|
||||||
'-V Verifies switch' \
|
'-r Convert to rocky' \
|
||||||
|
'-V Verify switch' \
|
||||||
' !! USE WITH CAUTION !!'
|
' !! USE WITH CAUTION !!'
|
||||||
exit 1
|
exit 1
|
||||||
} >&2
|
} >&2
|
||||||
@ -500,6 +516,14 @@ EOF
|
|||||||
dnf -y distro-sync || exit_message "Error during distro-sync."
|
dnf -y distro-sync || exit_message "Error during distro-sync."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Called to update the EFI boot.
|
||||||
|
fix_efi () (
|
||||||
|
grub2-mkconfig -o /boot/efi/EFI/rocky/grub.cfg ||
|
||||||
|
exit_message "Error updating the grub config."
|
||||||
|
efibootmgr -c -d "$efi_mount" -L "Rocky Linux" -I /EFI/rocky/grubx64.efi ||
|
||||||
|
exit_message "Error updating uEFI firmware."
|
||||||
|
)
|
||||||
|
|
||||||
## End actual work
|
## End actual work
|
||||||
|
|
||||||
noopts=0
|
noopts=0
|
||||||
@ -515,6 +539,9 @@ 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
|
||||||
@ -542,6 +569,10 @@ if [[ $verify_all_rpms && $convert_to_rocky ]]; then
|
|||||||
find /root/convert -type f -name "$HOSTNAME-rpms-*.log"
|
find /root/convert -type f -name "$HOSTNAME-rpms-*.log"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $update_efi && $convert_to_rocky ]]; then
|
||||||
|
fix_efi
|
||||||
|
fi
|
||||||
|
|
||||||
printf '\n\n\n'
|
printf '\n\n\n'
|
||||||
if [[ $convert_to_rocky ]]; then
|
if [[ $convert_to_rocky ]]; then
|
||||||
cat /etc/issue | awk 'NR<=15'
|
cat /etc/issue | awk 'NR<=15'
|
||||||
|
Loading…
Reference in New Issue
Block a user