[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Activating a configuration file within a submenu or a menuentry

From: Arbiel Perlacremaz
Subject: Re: Activating a configuration file within a submenu or a menuentry
Date: Sun, 08 Apr 2012 23:58:03 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120310 Thunderbird/11.0


The script begins with the definition all functions. other_cfg is the function which looks for the cfg files, discarting the present script, and generating the menu for all other cfg files.

The script searches for the "cielos" partition. If found, it call the boot_ciel function to boot directly into the partition, otherwise it calls the other_cfg files. Returning from this function, the scripts set the timeout variable to execute directly the found cfg file, or displays the menu to prompt the user, waiting indefinitely.

Here is my script

# Ce fichier n'est pas créé par les procédures classiques.
# This file is hand written, however some parts has been taken from the regular cfg file

if [ -s $prefix/grubenv ]; then
  set have_grubenv=true

function load_video {
  insmod vbe
  insmod vga
  insmod video_bochs
  insmod video_cirrus

# Recherche des fichiers grub.cfg et génération du menu lorsque cielos n\'existe pas # Looking for the grub.cfg files, and generating grub's menu, when cielos does not exist

function other_cfg {
insmod regexp

for device in (*); do
# il ne faut pas inclure dans le menu l\'amorçage actuel, pour éviter de tourner en rond # the present grub.cfg file is to be excluded from the menu, as to avoid looping on it
    if [ "${device}/boot/grub" != "${prefix}" ]; then
       if [ -e ${device}/boot/grub/grub.cfg ]; then
        echo J\'ai trouvé ${device}/boot/grub/grub.cfg;
         if probe --set=label --label "$device"; then
            menuentry "$label" {
                configfile  ${device}/boot/grub/grub.cfg
if [ -z ${entries} ]; then set entries=1; else set entries=2; fi
# si une seule ligne, entries = 1, sinon entries = 2
# if there is a single line, entries = 1, else entries = 2
# sert à initialer le temps d'attente après affichage du menu (0 ou -1)
# used to set the timeout waiting for the user's choice (0 or -1)


# amorçage à partir de la partition cielos si elle existe
# booting form cielos partition when it exists
function boot_ciel {
  set gfxpayload=$linux_gfx_mode
  insmod gzio
  insmod part_msdos
  insmod ext2
# echo chargement du noyay
linux /vmlinuz root=LABEL=${ciel} ro quiet splash pcie_aspm=force vt.handoff=7
# echo initialisation ramdisk
  initrd        /initrd.img

# préparation de l'affichage du menu, code extrait du fichier standard
# preparing for the display of the menu, this code is mainly taken from the regular cfg file
function prepboot {
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=auto
  insmod gfxterm
  insmod part_msdos
  insmod ext2
  set locale_dir=($root)/boot/grub/locale
  set lang=fr_FR
  insmod gettext
terminal_output gfxterm
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
if background_color 44,0,30; then
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
# echo calcul de linux_gfx_mode
if [ ${recordfail} != 1 ]; then
  if [ -e ${prefix}/gfxblacklist.txt ]; then
    if hwmatch ${prefix}/gfxblacklist.txt 3; then
      if [ ${match} = 0 ]; then
        set linux_gfx_mode=keep
        set linux_gfx_mode=text
      set linux_gfx_mode=text
    set linux_gfx_mode=keep
  set linux_gfx_mode=text
export linux_gfx_mode
if [ "$linux_gfx_mode" != "text" ]; then load_video; fi

# fin de la procédure prepboot
# end of prepboot procedure

# chargement des modules part_mdos et ext2
insmod part_msdos
insmod ext2

# recherche de la partition cielos, pour amorcer sur cette partition si elle existe
# looking for "cielos", and booting from it when it exists
 set ciel="cielos"
 set root=
 set entries=
 search --no-floppy --label --set=root ${ciel}
 if  [ -n ${root} ]; then other_cfg ; else set entries="0"; fi

if [ "${entries}" = "0"]; then
        echo Attendre la fin de la procédure de lancement du PC
set default=0
if [ "${entries}" = "1"]; then set timeout=0; else set timeout=-1; fi

### END /etc/grub.d/10_linux ###

Le 08/04/2012 21:50, Jordan Uggla a écrit :
On Apr 8, 2012 7:28 AM, "Arbiel Perlacremaz"
<address@hidden>  wrote:


I wrote a script looking for all the grub.cfg files present into a 
configuration and creating a menu to ask the user for his choice. I used the 
configfile command to activate the chosen grub.cfg file, but nothing happens. 
Grub loops on the displaying of the menu.

How should I do ?

Thank you for any advice.


Please post the exact script you're using / the grub.cfg which it generates.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]