Skip to content

Instantly share code, notes, and snippets.

@raffraffraff
Last active June 26, 2020 15:18
Show Gist options
  • Save raffraffraff/4f5caddb7754ae233086 to your computer and use it in GitHub Desktop.
Save raffraffraff/4f5caddb7754ae233086 to your computer and use it in GitHub Desktop.
Install latest ubuntu kernel
#!/bin/bash
# Author: Paul Rafferty <raffraffraff@gmail.com>
# Purpose: Finds, downloads and installs the latest upstream kernel for Ubuntu
# Note: If your host requires proprietary modules (eg: virtualbox, nvidia, fglrx, bcmwl etc) then
# you require the extra modules package which is not available here. You can try to uninstall
# these modules first before installing the upstream kernel. Otherwise, don't proceed - your
# new kernel probably won't boot.
# GIMME RIGHT NOW: curl -Ls https://goo.gl/VwBSVD | bash
# OPTIONS:
RC=no
# ENVIRONMENT:
BASEURL=http://kernel.ubuntu.com/~kernel-ppa/mainline
ARCH=$(dpkg --print-architecture)
DISTRIBUTION=$(awk -F= '/CODENAME/ {print $2}' /etc/lsb-release)
if [ "$RC" == "yes" ]; then
LATEST=$(curl -sL $BASEURL/ | html2text | grep -E '\[\[DIR\]\] *v[0-9]*.[0-9]*-(rc[0-9]-)*' | tail -n 1 | awk '{print $2}')
else
LATEST=$(curl -sL $BASEURL/ | html2text | grep -E '\[\[DIR\]\] *v[0-9]*.[0-9]*' | grep -v rc | tail -n 1 | awk '{print $2}')
fi
TMPDIR=$(mktemp -d); cd $TMPDIR
curl -sL $BASEURL/${LATEST}/ \
| grep linux \
| html2text -width 500 \
| grep -E '(_'$ARCH'|_all)' \
| grep -v lowlatency \
| sed "s#^.*${ARCH}/#${ARCH}/#g" | while read file; do
wget $BASEURL/${LATEST}/$file
done
sudo dpkg -i *.deb
sudo rm -f *.deb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment