Skip to content

Instantly share code, notes, and snippets.

@ivanalejandro0
Created June 25, 2015 22:17
Show Gist options
  • Save ivanalejandro0/cefa07dc0c16341cf09e to your computer and use it in GitHub Desktop.
Save ivanalejandro0/cefa07dc0c16341cf09e to your computer and use it in GitHub Desktop.
Linux kernel updater, tested on ubuntu/mint.
#!/bin/bash
# Inspired on:
# http://www.yourownlinux.com/2014/10/how-to-install-linux-kernel-3-17-stable-in-linux.html
# http://www.yourownlinux.com/2015/06/how-to-install-linux-kernel-4-1-0-in-linux.html
set -euo pipefail
IFS=$'\n\t'
# NOTE: you need to set this variable to the desired kernel you want
VERSION="v4.1-unstable"
echo -e "This script will: download, verify and install (asking first) the '$VERSION' kernel version.\n"
BASE="http://kernel.ubuntu.com/~kernel-ppa/mainline"
# get the list of files found on that folder
echo "Downloading file list..."
files=`wget -qO - $BASE/$VERSION/ | grep -oP '>\K(linux-image.*\.deb|linux-header.*\.deb)'`
if [[ `getconf LONG_BIT` == "64" ]]; then
ARCH='amd64'
else
ARCH='i386'
fi
# Strip out the file names that we need
# we use this regex since each kernel release has different numbers that
# doesn't matter for our purposes
headers_all=`echo $files | grep -o "linux-headers-[0-9\._-]*_all\.deb"`
headers_arch=`echo $files | grep -o "linux-headers-[0-9\._-]*-generic[0-9\._-]*_$ARCH\.deb"`
image_arch=`echo $files | grep -o "linux-image-[0-9\._-]*-generic[0-9\._-]*$ARCH\.deb"`
echo "Downloading packages and checksums..."
wget -qc $BASE/$VERSION/$headers_all $BASE/$VERSION/$headers_arch $BASE/$VERSION/$image_arch $BASE/$VERSION/CHECKSUMS
echo "Verifying checksums..."
shasum -c CHECKSUMS 2>&1 | grep -E "OK$|FAILED$" # this grep ignores non-existing files
echo
read -p 'Proceed with installation? (<ENTER> to continue, <CTRL+C> to abort) '
sudo dpkg -i *.deb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment