Skip to content

Instantly share code, notes, and snippets.

@amboxer21
Created July 8, 2020 15:36
Show Gist options
  • Save amboxer21/ed6a3c1156cb515cc4db6374e6ca4acd to your computer and use it in GitHub Desktop.
Save amboxer21/ed6a3c1156cb515cc4db6374e6ca4acd to your computer and use it in GitHub Desktop.
#!/bin/bash
path="/usr/bin"
new_kernel_version=$1
current_kernel=`${path}/uname -r`
boot=`${path}/sudo ${path}/fdisk -l | ${path}/awk '/\/.*\*/{print $1}'`
cd /usr/src/linux-${new_kernel_version};
if [[ ! `${path}/mount | ${path}/egrep -io "^${boot} on /boot"` ]]; then
$path/sudo $path/mount $boot /boot;
fi
if [[ $current_kernel != $new_kernel_version ]]; then
$path/cp -i /usr/src/linux-$current_kernel/.config /usr/src/linux-$new_kernel_version/;
$path/ls /usr/src/linux-$new_kernel_version/.config.old;
if [[ $? > 0 ]]; then
$path/make oldconfig;
fi
fi
$path/make -j5 && $path/make modules_install && $path/make install && $path/grub-mkconfig -o /boot/grub/grub.cfg;
rm -r /usr/src/linux && ln -s /usr/src/linux-${new_kernel_version} /usr/src/linux;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment