#!/usr/bin/env bash
: <<!
"We hardcode the GRUB_CMDLINE_LINUX_DEFAULT options for zbm in 020_grub_zbm_payload.sh"
!
exit 1

# | Parameter                   | Purpose                                            | Notes                                                             |
# | --------------------------- | -------------------------------------------------- | ----------------------------------------------------------------- |
# | zbm.prefer=<pool>           | Tells ZBM which ZFS pool to import first           | Highly recommended if you have multiple zpools or bootable clones |
# | zbm.import_delay=<seconds>  | Adds a startup delay before auto-importing pools   | Useful for slow disks or sparse device init                       |
# | zbm.readonly=1              | Forces all imports read‑only                       | For emergency/recovery boot entries                               |
# | zbm.timeout=<sec>           | Default menu timeout                               | Optional override of ZBM’s own internal timeout                   |
# | zbm.skip=<boolean>          | Skip pool discovery, assume you’ll import manually | Optional, advanced                                                |
# | loglevel=<n>                | Controls kernel verbosity                          | 4 is a balanced choice; 7 for deep debugging                      |
# | rd.vconsole.keymap=<keymap> | Keyboard layout for early TTY                      | Optional, good for non‑US systems                                 |
# | rd.vconsole.font=<font>     | Sets framebuffer console font (e.g. ter-124n)      | Helps when small fonts are hard to read on hi‑res screens         |

# Define arguments to add
# Font sizes     : ter-v32n ter-v28n ter-v24n ter-v20n ter-v14n
# Font sizes bold: ter-v32b ter-v28b ter-v24b ter-v20b ter-v14b
NEWARG=("rd.vconsole.font=ter-124n" "zbm.prefer=rpool" "loglevel=4" "zbm.import_delay=5")

# Loop through each argument and append to GRUB_CMDLINE_LINUX_DEFAULT
for arg in "${NEWARG[@]}"; do
  sudo sed -i -E "s|^(GRUB_CMDLINE_LINUX_DEFAULT=\"[^\"]*)\"|\1 ${arg}\"|" /etc/default/grub
done

# Update GRUB
sudo update-grub
