-
-
Save mmstick/8493727 to your computer and use it in GitHub Desktop.
| #!/bin/bash | |
| # Dependency | |
| sudo apt-get install lynx -y | |
| cd /tmp | |
| sudo rm *.deb | |
| # Kernel URL | |
| read -p "Do you want the latest RC?" rc | |
| case "$rc" in | |
| y*) kernelURL=$(lynx -dump http://kernel.ubuntu.com/~kernel-ppa/mainline/ | tail -1 | cut -d ' ' -f 3) ;; | |
| n*) kernelURL=$(lynx -dump http://kernel.ubuntu.com/~kernel-ppa/mainline/ | grep -v rc | tail -1 | cut -d ' ' -f 3) ;; | |
| esac | |
| read -p "Do you want the lowlatency kernel?" lowlatency | |
| case "$lowlatency" in | |
| y*) lowlatency=1 ;; | |
| n*) lowlatency=0 ;; | |
| esac | |
| echo "The latest kernel is $(echo $kernelURL | cut -d/ -f 6). The currently installed kernel is $(uname -r)." | |
| # Download Kernel | |
| if [ "$(uname -m)" == "x86_64" ] && [ "$lowlatency" == "0" ]; then | |
| echo "Downloading the latest 64-bit generic kernel." | |
| wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | sed -n '16p' | cut -d ' ' -f 4) | |
| wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | sed -n '20p' | cut -d ' ' -f 4) | |
| wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | sed -n '21p' | cut -d ' ' -f 4) | |
| elif [ "$(uname -m)" == "x86_64" ] && [ "$lowlatency" == "1" ]; then | |
| echo "Downloading the latest 64-bit lowlatency kernel." | |
| wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | sed -n '18p' | cut -d ' ' -f 4) | |
| wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | sed -n '20p' | cut -d ' ' -f 4) | |
| wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | sed -n '23p' | cut -d ' ' -f 4) | |
| elif [ "$(uname -m)" == "i386" ] && [ "$lowlatency" == "0" ]; then | |
| echo "Downloading the latest 32-bit generic kernel." | |
| wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | sed -n '17p' | cut -d ' ' -f 4) | |
| wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | sed -n '20p' | cut -d ' ' -f 4) | |
| wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | sed -n '22p' | cut -d ' ' -f 4) | |
| elif [ "$(uname -m)" == "i386" ] && [ "$lowlatency" == "1" ]; then | |
| echo "Downloading the latest 32-bit lowlatency kernel." | |
| wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | sed -n '19p' | cut -d ' ' -f 4) | |
| wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | sed -n '20p' | cut -d ' ' -f 4) | |
| wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | sed -n '24p' | cut -d ' ' -f 4) | |
| fi | |
| # Install Kernel | |
| echo "Installing Linux Kernel" | |
| sudo dpkg -i linux*.deb | |
| echo "Done. You may now reboot." |
Hello, how can i get the latest daily ubuntu kernel ?
Hello. Thanks for this useful script. Is there a reason why the latest stable kernel is not automatically downloaded? For example, latest stable kernel as of today in ~kernel-ppa/mainline/ is 4.9.6. However, on running the script, 4.9.0 is installed. I'm assuming that the script only looks at the 1st two digits of the kernel revision?
a quick fix is to add grep v[1-9].[1-9].[1-9] in the lynx dump command
edit: before the tail -n1
See at http://kernel.ubuntu.com/~kernel-ppa/mainline/ the page render 4.7.x folder after v4.7.10 folder.
He problem is how the script detect the last valid folder
The solution provided by @nicman23 not looks valid, will ignore folders like 4.13 or 4.13.1
Also http://kernel.ubuntu.com/~kernel-ppa/mainline/?C=M;O=A not works for me
Hey! Awesome script. Curious though that trying to download latest generic non-rc, and it downloads 4.7.0-XX instead of 4.7..2, which according to kernel.ubuntu is the latest as of 7 days ago. (in the website I just realized that the files are not in date order, so 4.7 appears below 4.7.2 even tho the latter is the latest). Sadly I don't know enough bash to suggest how to improve it.