bug-grub
[Top][All Lists]
Advanced

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

Bug#86750: installkernel example


From: Wichert Akkerman
Subject: Bug#86750: installkernel example
Date: Tue, 20 Feb 2001 15:48:36 +0100

Package: grub
Version: 0.5.96.1
Severity: wishlist

I wrote a little script to generate menu items for grub based on
the currently installed kernels. It seems to work fine for me,
if it is interesting enough feel free to include it with grub as
an example.

Wichert.


#! /bin/sh
#
# Insert a list of installed kernels in a grub menu.lst file
#   Copyright 2001 Wichert Akkerman <address@hidden>
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

# The file we will be modifying
menu=/boot/grub/menu.lst
# Default kernel options, overidden by the kopt statement in the menufile.
kopt="rw root=/dev/hda5"
# Make sure we use the standard sorting order
LC_COLLATE=C
# Magic markers we use
start="### BEGIN DEBIAN KERNELS"
end="### END DEBIAN KERNELS"

# Abort on errors
set -e

abort() {
        echo "$@" >&2
        exit 1
}

# Test if our template exists
[ -f "$menu" ] || abort "$menu does not exist, aborting"

# Extract the kernel options to use
tmp=$(sed -ne 's/# kopt=\(.*\)/\1/p' $menu)
[ "$tmp" = "" ] || kopt="$tmp"

# Generate the menu options we want to insert
buffer=$(tempfile)
echo $start >> $buffer
echo "# kopt=$kopt" >> $buffer
for i in /boot/vmlinuz-* ; do
        name=$(echo $i | sed -e 's/.*vmlinuz-//')
        echo "title Debian GNU/Linux, kernel $name" >> $buffer
        echo "kernel (hd0,4)$i $kopt"  >> $buffer
        echo >> $buffer
done
echo $end >> $buffer

# Insert the new options into the menu
if ! grep -q "^$start" $menu ; then
        cat $buffer >> $menu
else
        umask 077
        sed -e "/^$start/,/^$end/{
/^$start/r $buffer
d
}
" $menu > $menu.new
        cat $menu.new > $menu
        rm -f $buffer $menu.new
fi



-- System Information
Debian Release: testing/unstable
Architecture: i386
Kernel: Linux fog 2.2.18ext3 #1 Tue Feb 13 01:36:06 CET 2001 i686

Versions of packages grub depends on:
ii  libc6                         2.2.1-3    GNU C Library: Shared libraries an
ii  libncurses5                   5.0-8      Shared libraries for terminal hand





reply via email to

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