void-bash-installer/modules/50-bootloader/install

36 lines
1.5 KiB
Plaintext
Raw Normal View History

2021-03-11 14:04:04 +01:00
module start "bootloader" "Install Bootloader"
source "${vars}/disk"
diskid="${cfg[diskid]//-/_}"
2021-03-12 14:12:27 +01:00
if [[ ! "${cfg[fde_key_store]}" == "none" ]] && [[ ! "${cfg[fde_key_store]}" == "once" ]]; then
2021-03-11 14:04:04 +01:00
if ! grep -q "GRUB_ENABLE_CRYPTODISK" "${dest}"/etc/default/grub; then
echo "GRUB_ENABLE_CRYPTODISK=y" >> "${dest}"/etc/default/grub
2021-03-12 18:37:09 +01:00
fi
2021-03-11 14:04:04 +01:00
2021-03-12 18:09:57 +01:00
if [[ ! -f "${dest}"/boot/volume.key ]] && [[ ! "${cfg[fde_key_store]}" == "twice" ]]; then
2021-03-11 14:04:04 +01:00
dd bs=1 count=64 if=/dev/urandom of="${dest}"/boot/volume.key
echo -n "${cfg[diskpw]}" | cryptsetup luksAddKey "${cfg[diskname]}${cfg[target_part]}" "${dest}"/boot/volume.key -d -
chmod 000 "${dest}"/boot/volume.key
chmod -R g-rwx,o-rwx "${dest}"/boot
fi
2021-03-12 18:09:57 +01:00
sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT/s/=\"/=\"rd.luks.uuid=${cfg[partuuid]} rd.vconsole.keymap=${cfg[lang_console]} /" "${dest}"/etc/default/grub
2021-03-11 14:04:04 +01:00
fi
if ! grep -q rd.lvm.vg "${dest}"/etc/default/grub; then
2021-03-12 18:09:57 +01:00
sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT/s/=\"/=\"rd.lvm.vg=voidvg.${diskid} rd.vconsole.keymap=${cfg[lang_console]} /" "${dest}"/etc/default/grub
fi
if [[ "${cfg[hibernate]}" == "1" ]]; then
sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT/s/=\"/=\"resume=${cfg[swapuuid]} /" "${dest}"/etc/default/grub
2021-03-11 14:04:04 +01:00
fi
if [[ "${cfg[fde_key_store]}" == "initramfs" ]]; then
mkdir -p "${dest}"/etc/dracut.conf.d/
2021-03-12 18:09:57 +01:00
echo 'install_items+=" /boot/volume.key /etc/crypttab "' > "${dest}"/etc/dracut.conf.d/crypt-ssh.conf
echo "voidluks-${diskid} UUID=${cfg[partuuid]} /boot/volume.key luks" > "${dest}"/etc/crypttab
2021-03-11 14:04:04 +01:00
fi
2021-03-12 18:09:57 +01:00
module end