vinstaller/etc/bootloader/grub

104 lines
4.2 KiB
Plaintext
Raw Normal View History

2022-02-07 05:06:12 +01:00
packages() {
if [ "$EFI" == "1" ]; then
2022-02-07 19:29:15 +01:00
addpkg grub-x86_64-efi efibootmgr
2022-02-07 05:06:12 +01:00
else
addpkg grub
fi
2022-02-07 16:22:08 +01:00
}
config() {
2022-02-08 18:57:09 +01:00
if [ "${ENC}" == "1" ]; then
if ! grep -q "GRUB_ENABLE_CRYPTODISK" /etc/default/grub; then
echo "GRUB_ENABLE_CRYPTODISK=y" >> /etc/default/grub
fi
uuid=$(blkid -o value -s UUID ${TARGET_PHY_ID}-part${TARGET_PART})
if ! grep -q rd.luks.uuid /etc/default/grub; then
sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT/s/=\"/=\"rd.luks.uuid=${uuid} /" /etc/default/grub
fi
else
if ! grep -q "#GRUB_ENABLE_CRYPTODISK" /etc/default/grub; then
echo "#GRUB_ENABLE_CRYPTODISK=y" >> /etc/default/grub
fi
fi
if ! grep -q rd.lvm.vg /etc/default/grub; then
sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT/s/=\"/=\"rd.lvm.vg=vg_${TARGETNAME_UNDERSCORE} /" /etc/default/grub
2022-02-08 18:58:59 +01:00
fi
2022-02-09 09:56:09 +01:00
if ! [ "${KEY_LANG}" == "en" ]; then
2022-02-09 14:00:29 +01:00
if [ "${EFI}" == "1" ]; then
2022-02-09 19:33:39 +01:00
VGUUID="$(vgdisplay |grep UUID|awk '{print $3}')"
LVUUID="$(lvdisplay "/dev/mapper/vg_${TARGETNAME_UNDERSCORE}-root" |grep UUID|awk '{print $3}')"
rl="$(basename $(readlink "${TARGET_PHY_ID}-part${TARGET_PART}"))"
2022-02-09 19:34:47 +01:00
TMP="$(lsblk -o NAME,UUID -l|grep "${rl} " | awk '{print $2}')"
2022-02-09 19:33:39 +01:00
CRYPTUUID="${TMP//-/}"
2022-02-09 13:17:24 +01:00
2022-02-09 16:30:38 +01:00
mkdir -p /boot/efi/EFI/void /boot/grub
2022-02-09 16:40:46 +01:00
grub-kbdcomp -o /boot/grub/${KEY_LANG}.gkb ${KEY_LANG}
2022-02-09 17:05:42 +01:00
tar cf /boot/grub/memdisk.tar /boot/grub/${KEY_LANG}.gkb
2022-02-09 20:38:54 +01:00
#echo "set root=(memdisk)" > /boot/grub/early-grub.cfg
#echo "set prefix=(\$root)/" >> /boot/grub/early-grub.cfg
2022-02-09 19:12:52 +01:00
echo "insmod gzio" >> /boot/grub/early-grub.cfg
2022-02-09 18:24:38 +01:00
echo "insmod part_gpt" >> /boot/grub/early-grub.cfg
echo "insmod cryptodisk" >> /boot/grub/early-grub.cfg
echo "insmod luks" >> /boot/grub/early-grub.cfg
echo "insmod gcry_rijndael" >> /boot/grub/early-grub.cfg
echo "insmod gcry_rijndael" >> /boot/grub/early-grub.cfg
echo "insmod gcry_sha256" >> /boot/grub/early-grub.cfg
echo "insmod lvm" >> /boot/grub/early-grub.cfg
echo "insmod btrfs" >> /boot/grub/early-grub.cfg
echo "insmod memdisk" >> /boot/grub/early-grub.cfg
echo "insmod tar" >> /boot/grub/early-grub.cfg
echo "insmod at_keyboard" >> /boot/grub/early-grub.cfg
echo "insmod keylayouts" >> /boot/grub/early-grub.cfg
echo "insmod configfile" >> /boot/grub/early-grub.cfg
echo "insmod all_video" >> /boot/grub/early-grub.cfg
2022-02-09 14:00:29 +01:00
echo "terminal_input at_keyboard" >> /boot/grub/early-grub.cfg
2022-02-09 19:55:42 +01:00
echo "keymap /boot/grub/${KEY_LANG}.gkb" >> /boot/grub/early-grub.cfg
2022-02-09 20:38:54 +01:00
#echo "cryptomount -u ${CRYPTUUID}" >> /boot/grub/early-grub.cfg
2022-02-09 20:06:49 +01:00
echo "cryptomount -a" >> /boot/grub/early-grub.cfg
2022-02-09 20:38:54 +01:00
echo "unset prefix" >> /boot/grub/early-grub.cfg
2022-02-09 20:15:04 +01:00
echo "set root='lvm/vg_${TARGETNAME_UNDERSCORE}-root'" >> /boot/grub/early-grub.cfg
2022-02-09 20:06:49 +01:00
#echo "set prefix=($root)/rootfs/boot/grub" >> /boot/grub/early-grub.cfg
2022-02-09 20:38:54 +01:00
echo "configfile (\$root)/rootfs/boot/grub.cfg" >> /boot/grub/early-grub.cfg
2022-02-09 13:17:24 +01:00
2022-02-09 19:33:39 +01:00
echo "#!/bin/bash" > /usr/bin/gen-grub
echo "cd /" >> /usr/bin/gen-grub
2022-02-09 19:55:42 +01:00
#echo "cp -rf /boot/grub/memdisk.tar /boot/grub/early-grub.cfg ." >> /usr/bin/gen-grub
echo "grub-mkimage -c /boot/grub/early-grub.cfg -o grubx64_de.efi -O x86_64-efi -m /boot/grub/memdisk.tar gzio part_gpt cryptodisk luks gcry_rijndael gcry_rijndael gcry_sha256 lvm btrfs memdisk tar at_keyboard keylayouts configfile all_video" >> /usr/bin/gen-grub
2022-02-09 20:06:49 +01:00
echo "mv -f /grubx64_de.efi /boot/efi/EFI/void/grubx64_de.efi" >> /usr/bin/gen-grub
2022-02-09 19:12:52 +01:00
chmod +x /usr/bin/gen-grub
gen-grub
2022-02-09 13:17:24 +01:00
2022-02-09 14:00:29 +01:00
fi
2022-02-09 09:56:09 +01:00
if ! grep -q rd.console.keymap /etc/default/grub; then
2022-02-08 18:57:09 +01:00
sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT/s/=\"/=\" rd.vconsole.keymap=${L2} /" /etc/default/grub
2022-02-09 09:56:09 +01:00
fi
fi
2022-02-08 18:57:09 +01:00
uuid=$(blkid -o value -s UUID /dev/mapper/vg_${TARGETNAME_UNDERSCORE}-swap)
if [[ "${HIBERNATE}" == "1" ]]; then
sed -i "/^GRUB_CMDLINE_LINUX_DEFAULT/s/=\"/=\"resume=UUID=${uuid} /" /etc/default/grub
fi
if ! grep -q "dark-gray/black" /etc/default/grub; then
echo "GRUB_COLOR_NORMAL=\"dark-gray/black\"" >> /etc/default/grub
2022-02-09 01:54:57 +01:00
echo "GRUB_COLOR_HIGHLIGHT=\"green/black\"" >> /etc/default/grub
2022-02-08 18:57:09 +01:00
fi
2022-02-07 19:10:58 +01:00
if [ "${EFI}" == "1" ]; then
2022-02-09 16:43:11 +01:00
grub-install --bootloader-id="Voidlinux"
2022-02-09 16:01:24 +01:00
efibootmgr --create --disk "${TARGET_PHY_ID}-part1" --loader /EFI/void/grubx64_de.efi --label "Voidlinux DE" --verbose
2022-02-07 16:22:08 +01:00
else
2022-02-07 19:10:58 +01:00
grub-install "${TARGET_PHY_ID}"
2022-02-08 18:57:09 +01:00
fi
2022-02-07 20:00:29 +01:00
lv=$(xbps-query linux|grep pkgver|awk '{print $2}')
lv1="${lv//-/}"
lv2="${lv1%_*}"
xbps-reconfigure -f "${lv2}"
2022-02-09 01:54:57 +01:00
}