lkml.org 
[lkml]   [1996]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subject[SCRIPT] Versioned Boot Menu: BootGen


I've seen a few messages about dealing with multilple linux kernels and
thought I would extend my lilo config to deal with this.

Here's my /sbin/installkernel and assosiated bits that generates a boot
menu out of the available kernel images.

Just hacked this up tonight to no guarantees about it's
stablity/usefulness on any system other than mine.

Hope it is of use to someone.

BTW, I'm calling it it BootGen unless the name has been used by someone
else already.

TTFN

--
Darren J Moffat


---8<--CUT HERE--------------------------------------------------------

#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1996-05-08 01:47 BST by <darren@xarius>.
# Source directory was `/usr/local/home/darren'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 2295 -rwxr-xr-x /sbin/installkernel
# 181 -rw-r--r-- /etc/lilo/README
# 481 -rw-r--r-- /etc/lilo/lilo.conf
# 183 -rw-r--r-- /etc/lilo/lilo.conf.head
# 51 -rw-r--r-- /etc/lilo/lilo.conf.options
# 0 -rw-r--r-- /etc/lilo/lilo.conf.tail
# 107 -rw-r--r-- /etc/lilo/lilo.menu
# 52 -rw-r--r-- /etc/lilo/lilo.menu.head
# 29 -rw-r--r-- /etc/lilo/lilo.menu.tail
# 50 -rw-r--r-- /etc/lilo/lilo.menu.txt
#
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
shar_touch=touch
else
shar_touch=:
echo
echo 'WARNING: not restoring timestamps. Consider getting and'
echo "installing GNU \`touch', distributed in GNU File Utilities..."
echo
fi
rm -f 1231235999 $$.touch
#
# ============= /sbin/installkernel ==============
if test ! -d '/sbin'; then
echo 'x - creating directory /sbin'
mkdir '/sbin'
fi
if test -f '/sbin/installkernel' && test X"$1" != X"-c"; then
echo 'x - skipping /sbin/installkernel (file already exists)'
else
echo 'x - extracting /sbin/installkernel (text)'
sed 's/^X//' << 'SHAR_EOF' > '/sbin/installkernel' &&
#!/bin/sh
#
# Current Version:
# $Id: installkernel,v 1.3 1996/05/08 00:42:11 darren Exp $
#
# Creates a boot menu of all known linux targets with a given prefix.
# Note that This script assumes that Linux targets appear last in the menu.
#
# Params from Linux Kernel Makefile:
# Version x.y.z
# Kernel Image (usually zImage)
# System.map
# Install Path
#
# $Log: installkernel,v $
# Revision 1.3 1996/05/08 00:42:11 darren
# Adjusted kernel image search to use prefix and suffix
#
# Revision 1.2 1996/05/08 00:28:23 darren
# Changed first occurence of MAP_SUFFIX to MAP_PREFIX, oops
#
# Revision 1.1.1.1 1996/05/08 00:21:17 darren
# Initial Version
#
X
X
VERSION=$1
IMAGE=$2
SYSMAP=$3
INSTALL_PATH=${4:-/boot}
X
IMAGE_PREFIX=vmlinuz-
IMAGE_SUFFIX=
MAP_PREFIX=System.map-
MAP_SUFFIX=
X
LILO_CONF=/etc/lilo/lilo.conf
LILO_MENU=/etc/lilo/lilo.menu
X
rm -f $LILO_CONF $LILO_MENU
X
cat <<EOM
===========================================================================
= Starting Kernel Install of $VERSION as $INSTALL_PATH/vmlinuz-$VERSION
===========================================================================
X
EOM
X
echo "Placing kernel files in $INSTALL_PATH..."
cp $IMAGE $INSTALL_PATH/${IMAGE_PREFIX}${VERSION}${IMAGE_SUFFIX}
cp $SYSMAP $INSTALL_PATH/${MAP_PREFIX}-${VERSION}${MAP_SUFFIX}
X
echo "Creating Lilo Menu..."
X
X
X
cat >> $LILO_CONF <<EOM
# Created By BootGen `date`
X
message = $LILO_MENU
X
EOM
X
touch $LILO_MENU
X
cat ${LILO_CONF}.head >> $LILO_CONF
X
cat ${LILO_MENU}.head >> $LILO_MENU
X
X
echo "# == Linux Kernels ==" >> $LILO_CONF
X
# Attempt to calculate the menu start number [major hack :-)]
n=$[`grep -c other $LILO_CONF`+1]
X
for i in `ls -1 $INSTALL_PATH/${IMAGE_PREFIX}*${IMAGE_SUFFIX}`
do
X echo image = $i >> $LILO_CONF
X cat ${LILO_CONF}.options >> $LILO_CONF
X
X label=`basename $i | cut -c9-` # NB 9 comes from length(KERNEL_IMAGE)
X echo " label = $n" >> $LILO_CONF
X
X echo "$n. $label" >> $LILO_MENU
X n=$[n+1]
done
X
cat ${LILO_MENU}.tail >> $LILO_MENU
X
cat ${LILO_CONF}.tail >> $LILO_CONF
X
echo "# == EOF ==" >> $LILO_CONF
X
X
echo "Installing Lilo Menu..."
lilo -C $LILO_CONF
X
cat <<EOM
===========================================================================
= Installation Complete
===========================================================================
EOM
SHAR_EOF
$shar_touch -am 0508014296 '/sbin/installkernel' &&
chmod 0755 '/sbin/installkernel' ||
echo 'restore of /sbin/installkernel failed'
shar_count="`wc -c < '/sbin/installkernel'`"
test 2295 -eq "$shar_count" ||
echo "/sbin/installkernel: original size 2295, current size $shar_count"
fi
# ============= /etc/lilo/README ==============
if test ! -d '/etc'; then
echo 'x - creating directory /etc'
mkdir '/etc'
fi
if test ! -d '/etc/lilo'; then
echo 'x - creating directory /etc/lilo'
mkdir '/etc/lilo'
fi
if test -f '/etc/lilo/README' && test X"$1" != X"-c"; then
echo 'x - skipping /etc/lilo/README (file already exists)'
else
echo 'x - extracting /etc/lilo/README (text)'
sed 's/^X//' << 'SHAR_EOF' > '/etc/lilo/README' &&
These files are intended for use with the bootgen kernel install
script only.
X
The naming of this dir (/etc/lilo) may conflict with an old name of a dir
/etc/lilo on some systems.
X
SHAR_EOF
$shar_touch -am 0508014096 '/etc/lilo/README' &&
chmod 0644 '/etc/lilo/README' ||
echo 'restore of /etc/lilo/README failed'
shar_count="`wc -c < '/etc/lilo/README'`"
test 181 -eq "$shar_count" ||
echo "/etc/lilo/README: original size 181, current size $shar_count"
fi
# ============= /etc/lilo/lilo.conf ==============
if test -f '/etc/lilo/lilo.conf' && test X"$1" != X"-c"; then
echo 'x - skipping /etc/lilo/lilo.conf (file already exists)'
else
echo 'x - extracting /etc/lilo/lilo.conf (text)'
sed 's/^X//' << 'SHAR_EOF' > '/etc/lilo/lilo.conf' &&
# Created By BootGen Wed May 8 01:30:40 BST 1996
X
message = /etc/lilo/lilo.menu
X
# == Global ==
boot = /dev/hda
timeout = 50
prompt
vga = ext # force sane state
ramdisk = 0 # paranoia setting
X
# == MS-DOS ==
other = /dev/hda1
X table = /dev/hda
X label = 1
X
X
# == Linux Kernels ==
image = /boot/vmlinuz-1.3.88
X root = /dev/hdb1
X append="sbpcd=0x0630,LaserMate"
X label = 2
image = /boot/vmlinuz-1.3.97
X root = /dev/hdb1
X append="sbpcd=0x0630,LaserMate"
X label = 3
# == EOF ==
SHAR_EOF
$shar_touch -am 0508013096 '/etc/lilo/lilo.conf' &&
chmod 0644 '/etc/lilo/lilo.conf' ||
echo 'restore of /etc/lilo/lilo.conf failed'
shar_count="`wc -c < '/etc/lilo/lilo.conf'`"
test 481 -eq "$shar_count" ||
echo "/etc/lilo/lilo.conf: original size 481, current size $shar_count"
fi
# ============= /etc/lilo/lilo.conf.head ==============
if test -f '/etc/lilo/lilo.conf.head' && test X"$1" != X"-c"; then
echo 'x - skipping /etc/lilo/lilo.conf.head (file already exists)'
else
echo 'x - extracting /etc/lilo/lilo.conf.head (text)'
sed 's/^X//' << 'SHAR_EOF' > '/etc/lilo/lilo.conf.head' &&
# == Global ==
boot = /dev/hda
timeout = 50
prompt
vga = ext # force sane state
ramdisk = 0 # paranoia setting
X
# == MS-DOS ==
other = /dev/hda1
X table = /dev/hda
X label = 1
X
X
SHAR_EOF
$shar_touch -am 0508005496 '/etc/lilo/lilo.conf.head' &&
chmod 0644 '/etc/lilo/lilo.conf.head' ||
echo 'restore of /etc/lilo/lilo.conf.head failed'
shar_count="`wc -c < '/etc/lilo/lilo.conf.head'`"
test 183 -eq "$shar_count" ||
echo "/etc/lilo/lilo.conf.head: original size 183, current size $shar_count"
fi
# ============= /etc/lilo/lilo.conf.options ==============
if test -f '/etc/lilo/lilo.conf.options' && test X"$1" != X"-c"; then
echo 'x - skipping /etc/lilo/lilo.conf.options (file already exists)'
else
echo 'x - extracting /etc/lilo/lilo.conf.options (text)'
sed 's/^X//' << 'SHAR_EOF' > '/etc/lilo/lilo.conf.options' &&
X root = /dev/hdb1
X append="sbpcd=0x0630,LaserMate"
SHAR_EOF
$shar_touch -am 0508005496 '/etc/lilo/lilo.conf.options' &&
chmod 0644 '/etc/lilo/lilo.conf.options' ||
echo 'restore of /etc/lilo/lilo.conf.options failed'
shar_count="`wc -c < '/etc/lilo/lilo.conf.options'`"
test 51 -eq "$shar_count" ||
echo "/etc/lilo/lilo.conf.options: original size 51, current size $shar_count"
fi
# ============= /etc/lilo/lilo.conf.tail ==============
if test -f '/etc/lilo/lilo.conf.tail' && test X"$1" != X"-c"; then
echo 'x - skipping /etc/lilo/lilo.conf.tail (file already exists)'
else
echo 'x - extracting /etc/lilo/lilo.conf.tail (empty)'
> '/etc/lilo/lilo.conf.tail' &&
$shar_touch -am 0508005496 '/etc/lilo/lilo.conf.tail' &&
chmod 0644 '/etc/lilo/lilo.conf.tail' ||
echo 'restore of /etc/lilo/lilo.conf.tail failed'
shar_count="`wc -c < '/etc/lilo/lilo.conf.tail'`"
test 0 -eq "$shar_count" ||
echo "/etc/lilo/lilo.conf.tail: original size 0, current size $shar_count"
fi
# ============= /etc/lilo/lilo.menu ==============
if test -f '/etc/lilo/lilo.menu' && test X"$1" != X"-c"; then
echo 'x - skipping /etc/lilo/lilo.menu (file already exists)'
else
echo 'x - extracting /etc/lilo/lilo.menu (text)'
sed 's/^X//' << 'SHAR_EOF' > '/etc/lilo/lilo.menu' &&
XXarius Boot Loader
==================
X
1. MS-DOS
2. 1.3.88
3. 1.3.97
Please select a boot Option:
SHAR_EOF
$shar_touch -am 0508013096 '/etc/lilo/lilo.menu' &&
chmod 0644 '/etc/lilo/lilo.menu' ||
echo 'restore of /etc/lilo/lilo.menu failed'
shar_count="`wc -c < '/etc/lilo/lilo.menu'`"
test 107 -eq "$shar_count" ||
echo "/etc/lilo/lilo.menu: original size 107, current size $shar_count"
fi
# ============= /etc/lilo/lilo.menu.head ==============
if test -f '/etc/lilo/lilo.menu.head' && test X"$1" != X"-c"; then
echo 'x - skipping /etc/lilo/lilo.menu.head (file already exists)'
else
echo 'x - extracting /etc/lilo/lilo.menu.head (text)'
sed 's/^X//' << 'SHAR_EOF' > '/etc/lilo/lilo.menu.head' &&
XXarius Boot Loader
==================
X
1. MS-DOS
SHAR_EOF
$shar_touch -am 0508005496 '/etc/lilo/lilo.menu.head' &&
chmod 0644 '/etc/lilo/lilo.menu.head' ||
echo 'restore of /etc/lilo/lilo.menu.head failed'
shar_count="`wc -c < '/etc/lilo/lilo.menu.head'`"
test 52 -eq "$shar_count" ||
echo "/etc/lilo/lilo.menu.head: original size 52, current size $shar_count"
fi
# ============= /etc/lilo/lilo.menu.tail ==============
if test -f '/etc/lilo/lilo.menu.tail' && test X"$1" != X"-c"; then
echo 'x - skipping /etc/lilo/lilo.menu.tail (file already exists)'
else
echo 'x - extracting /etc/lilo/lilo.menu.tail (text)'
sed 's/^X//' << 'SHAR_EOF' > '/etc/lilo/lilo.menu.tail' &&
Please select a boot Option:
SHAR_EOF
$shar_touch -am 0508005496 '/etc/lilo/lilo.menu.tail' &&
chmod 0644 '/etc/lilo/lilo.menu.tail' ||
echo 'restore of /etc/lilo/lilo.menu.tail failed'
shar_count="`wc -c < '/etc/lilo/lilo.menu.tail'`"
test 29 -eq "$shar_count" ||
echo "/etc/lilo/lilo.menu.tail: original size 29, current size $shar_count"
fi
# ============= /etc/lilo/lilo.menu.txt ==============
if test -f '/etc/lilo/lilo.menu.txt' && test X"$1" != X"-c"; then
echo 'x - skipping /etc/lilo/lilo.menu.txt (file already exists)'
else
echo 'x - extracting /etc/lilo/lilo.menu.txt (text)'
sed 's/^X//' << 'SHAR_EOF' > '/etc/lilo/lilo.menu.txt' &&
2. 1.3.88
3. 1.3.97
4. current
5. old
SHAR_EOF
$shar_touch -am 0508005596 '/etc/lilo/lilo.menu.txt' &&
chmod 0644 '/etc/lilo/lilo.menu.txt' ||
echo 'restore of /etc/lilo/lilo.menu.txt failed'
shar_count="`wc -c < '/etc/lilo/lilo.menu.txt'`"
test 50 -eq "$shar_count" ||
echo "/etc/lilo/lilo.menu.txt: original size 50, current size $shar_count"
fi
exit 0



\
 
 \ /
  Last update: 2005-03-22 13:37    [W:0.107 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site