refactor(zbm): Add ZBM postconf hook (#3)

We're adding this to our chroot after we've
generated a ZBM UEFI image file /without/
this hook script. It's meant to run only in our real
OS.
This commit is contained in:
hygienic-books 2023-10-21 05:07:02 +02:00
parent dcc3cf7d93
commit 598b176ec6

View File

@ -18,6 +18,7 @@ exec 3>&1
declare this_script_url
this_script_url="${SCRIPT_URL:?}"
postconf_hook="$(dirname "${this_script_url}")"'/zbm_set_new_uefi_boot_entries.sh'
declare zpool_name zfs_arch_dataset_name
zpool_name='zpool'
@ -674,21 +675,10 @@ function add_zbm_to_efi () {
local efi_disks_list
efi_disks_list="$(get_disks_with_one_efipart)"
if grep -Piq -- '^'"${efi_drive}"'$' <<<"${efi_disks_list}"; then
efibootmgr --disk "${efi_drive}" \
--part 1 \
--create \
--label "ZFSBootMenu recovery" \
--loader "\EFI\zbm\zfsbootmenu-recovery-vmlinuz-x86_64.EFI" \
--verbose
efibootmgr --disk "${efi_drive}" \
--part 1 \
--create \
--label "ZFSBootMenu release" \
--loader "\EFI\zbm\zfsbootmenu-release-vmlinuz-x86_64.EFI" \
--verbose
fi
efibootmgr
fi
function insert_zbm_postconf_hook () {
declare postconf_target_abs='/mnt/etc/zfsbootmenu/posthooks.d/'"$(basename "${postconf_hook}")"
curl --silent --location "${postconf_hook}" --output "${postconf_target_abs}"
chmod +x "${postconf_target_abs}"
}
function umount_all () {
@ -707,7 +697,7 @@ function finalize_os_setup () {
configure_zfs #3.6
configure_zfs_mount_gen #3.7
configure_zfsbootmenu #3.8
add_zbm_to_efi #3.9
insert_zbm_postconf_hook
umount_all #3.11
}