Azimout's Linux weblog script

leave a comment »

I have written a script that automates for me the task of installing a new kernel. That is, after I have done all the ketchup, config and make stuff, I would have to install the kernel, its modules, create and populate a new subdirectory under /lib/firmware, and update the initrd. This script does all this automatically. This was my first serious bash script, so I found the Advanced Bash-Scripting Guide very helpful.

# azimout: this script installs a given kernel version
# it takes the new kernel version from the Makefile
# it will install the kernel and its modules
# it will create the appropriate /lib/firmware sub-directory if missing
# and it will update the ramdisk

CURRENT_KERNEL=$(uname -r)
VAR1=$(grep -w 'VERSION =' Makefile | awk '{print $3}')
VAR2=$(grep -w 'PATCHLEVEL =' Makefile | awk '{print $3}')
VAR3=$(grep -w 'SUBLEVEL =' Makefile | awk '{print $3}')
VAR4=$(grep -w 'EXTRAVERSION =' Makefile | awk '{print $3}')

read -p "Installing the kernel and modules; press any key..."
sudo make modules_install install

  read -p "Copying firmware from $CURRENT_KERNEL to $NEW_KERNEL; press any key..."
  cd /lib/firmware
  sudo mkdir $NEW_KERNEL
  sudo cp -r $CURRENT_KERNEL/* -t $NEW_KERNEL

  read -p "Creating the ramdisk; press any key..."
  sudo update-initramfs -k $NEW_KERNEL -c
  read -p "Updating the ramdisk; press any key..."
  sudo update-initramfs -k $NEW_KERNEL -u

echo "You still need to edit the grub menu file manually..."

Written by azimout

17/06/2008 at 10:15

Posted in Tricks

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: