Uwe Ohse

available software

My /sbin/installkernel

This is my slightly modified /sbin/installkernel script (it get's called if i do a make install for a new linuxkernel).
I install my kernels in /kernel (and delete old kernels about twice a year).


#!/bin/sh
# Arguments:
#   $1 - kernel version
#   $2 - kernel image file
#   $3 - kernel map file
#   $4 - default install path (blank if root directory)
#
fdir=$4/kernel/
fname=$1
fcount=0
$liloconf=$4/etc/lilo.conf

mkdir $fdir 2>/dev/null

fthis=$fdir/$fname
while [ -f $fthis ] ; do
        fcount=`expr $fcount + 1`
        fname=$1.$fcount
        fthis=$fdir/$fname
done

echo will install as $fthis

awk -v fname="$fname" -v fthis="$fthis" '
BEGIN { found=0 }
/^image.*=/ & found==0 {
        print "image = " fthis
        print "    label = " fname
        print "    root = /dev/sda3"
        print "    vga = NORMAL"
        print "    append=\"pas16=0x388,14\""
        print "    read-only"
        found=1
}
{ print }
' <$4/etc/lilo.conf >$4/etc/lilo.conf.neu
if [ $? -ne 0 ] ; then
        echo "error installing new kernel. (awk error)" >&2
        rm -f /etc/lilo.conf.neu
        exit 1
fi 

cp -a $2 $fthis
if [ $? -ne 0 ] ; then
        echo "error installing new kernel. (cp kernel)" >&2
        rm -f $4/etc/lilo.conf.neu
        rm -f $fthis
        exit 1
fi 

cp -a $4/etc/lilo.conf $4/etc/lilo.conf.old
if [ $? -ne 0 ] ; then
        echo "error installing new kernel. (backup lilo conf)" >&2
        rm -f /etc/lilo.conf.neu
        rm -f $fthis
        rm -f /etc/lilo.conf.old
        exit 1
fi 
cp -a /etc/lilo.conf.neu /etc/lilo.conf
if [ $? -ne 0 ] ; then
        rm -f /etc/lilo.conf.neu
        rm -f $fthis
        mv -f /etc/lilo.conf.old /etc/lilo.conf
        echo "error installing new kernel. (installing new lilo.conf)" >&2
        exit 1
fi 
rm -f /etc/lilo.conf.neu

/sbin/lilo
if [ $? -ne 0 ] ; then
        echo "error installing new kernel. (lilo error)" >&2
        rm -f /etc/lilo.conf.neu
        rm -f $fthis
        exit 1
fi 

cp -a $3 $fthis.map
if [ $? -ne 0 ] ; then
        echo "error installing new kernel. (cp mapfile)" >&2
        exit 1
fi 
cp -a /usr/src/linux/.config $fthis.config
if [ $? -ne 0 ] ; then
        echo "error installing new kernels .config" >&2
        exit 1
fi 
ln -sf $fthis.map $4/nextboot.map
if [ $? -ne 0 ] ; then
        echo "error installing new kernel. (symlink mapfile)" >&2
        exit 1
fi 

Return to Uwe's home page.

Please send comments on these web pages and questions to uwe@ohse.de.

Copyright (C) 1996,1997,1998 Uwe Ohse.

Verbatim copying and distribution is permitted in any medium, provided this notice is preserved.