Script to install a new kernel

#!/bin/sh
#
# (c) Hunterwala

if [ $(/usr/bin/id -u) -ne 0 ]; then
     echo "run this script with sudo"
     exit 2
fi

if [ -z $1 ]; then
     echo "kernel version not found"
     echo "usage: ./install_kernel [kernel_version]"
     exit 2
else
     VERSION=$1
     echo "using $VERSION"
fi

if [ ! -d /lib/modules/$VERSION ]; then
     echo "kernel modules not installed"
     echo "run make install_modules from the kernel directory"
     exit 2
fi

BOOTDIR=/boot

echo "Installing kernel ........................"
cp $PWD/.config $BOOTDIR/config-$VERSION
cp $PWD/System.map $BOOTDIR/System.map-$VERSION
cp $PWD/arch/i386/boot/bzImage $BOOTDIR/vmlinuz-$VERSION
echo "done"

echo "Creating initrd image ...................."
update-initramfs -c -k $VERSION
echo "done"

echo "Updating grub ............................"
update-grub
echo "done"

echo "Linux kernel $VERSION successfully installed"
echo "Please restart and select $VERSION in grub menu"


No comments: