# Set the default menu entry to boot
set default=0

# Set the timeout for the GRUB menu
set timeout=5

# Set the GRUB background image (optional)
if loadfont /boot/grub/fonts/unicode.pf2; then
  insmod gfxterm
  insmod png
  set gfxmode=auto
  set background_image="/boot/grub/background.png"
  terminal_output gfxterm
fi

# Define the superuser and plain-text password (for demo purposes only)
set superusers="admin"
password admin myplaintextpassword

# Load necessary modules for Linux booting
insmod gzio
insmod part_msdos
insmod ext2

# Specify the path to the main GRUB boot configuration
set root='hd0,msdos1'
search --no-floppy --fs-uuid --set=root 1234-5678

# Boot menu entries
menuentry 'Ubuntu 22.04 LTS' --class ubuntu --class gnu-linux --class os {
    recordfail
    load_video
    gfxmode $linux_gfx_mode
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos1'
    linux /vmlinuz-5.15.0-30-generic root=UUID=1234-5678 ro quiet splash
    initrd /initrd.img-5.15.0-30-generic
}

# Protected entry for recovery mode (requires superuser password)
menuentry 'Ubuntu 22.04 LTS (Recovery Mode)' --class ubuntu --class gnu-linux --class os --unrestricted {
    recordfail
    load_video
    gfxmode $linux_gfx_mode
    insmod gzio
    insmod part_msdos
    insmod ext2
    set root='hd0,msdos1'
    linux /vmlinuz-5.15.0-30-generic root=UUID=1234-5678 ro recovery nomodeset
    initrd /initrd.img-5.15.0-30-generic
}

# Additional entry for Windows booting (if dual-booted)
menuentry 'Windows 10' --class windows --class os {
    insmod part_msdos
    insmod ntfs
    set root='hd0,msdos2'
    chainloader +1
}

# Boot to GRUB command line (restricted access, requires superuser password)
menuentry 'GRUB Command Line' --class cmdline --unrestricted {
    insmod all_video
    terminal_input console
    terminal_output console
}
