#!/bin/bash # grub-mkconfig — Generate GRUB configuration file (Red Bear OS wrapper) # # Compatibility: Matches GNU GRUB grub-mkconfig CLI conventions. # Generates a grub.cfg for chainloading the Redox bootloader. # # Usage: # grub-mkconfig [-o FILE] # grub-mkconfig --output=/boot/grub/grub.cfg set -euo pipefail PROG="$(basename "$0")" OUTPUT="" TIMEOUT=5 DEFAULT=0 usage() { cat <&2 echo "Try '$PROG --help' for more information." >&2 exit 1 ;; esac done case "$TIMEOUT" in ''|*[!0-9]*) echo "$PROG: invalid timeout '$TIMEOUT' (must be a non-negative integer)" >&2; exit 1;; esac generate_config() { cat </dev/null || date) # Red Bear OS GRUB configuration — chainloads the Redox bootloader set timeout=$TIMEOUT set default=$DEFAULT menuentry "Red Bear OS" { chainloader /EFI/REDBEAR/redbear.efi boot } menuentry "Reboot" { reboot } menuentry "Shutdown" { halt } GRUBCFG } if [ -n "$OUTPUT" ]; then generate_config > "$OUTPUT" else generate_config fi