Created
June 5, 2013 08:08
-
-
Save omegahanggara/5712345 to your computer and use it in GitHub Desktop.
You can Upgrade Your Linux Kernel to The Latest Version on https://www.kernel.org by using this script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Variable | |
currentKernel=$(uname -r) | |
latestKernel=$(curl https://www.kernel.org/ -s | sed -n "/<td id=\"latest_link\">/,/<\/td>/p" | sed -n -e 's/.*<a.*>\(.*\)<\/a>.*/\1/p'); | |
urlLatestKernel=$(echo "https://www.kernel.org$(curl https://www.kernel.org/ -s | grep $latestKernel | grep downloadarrow | awk -F "<" {'print $2'} | sed "s/a href\=\".\|\">//g")") | |
# Function | |
cin() { | |
if [ "$1" == "action" ] ; then output="\e[01;32m[>]\e[00m" ; fi | |
if [ "$1" == "info" ] ; then output="\e[01;33m[i]\e[00m" ; fi | |
if [ "$1" == "error" ] ; then output="\e[01;31m[!]\e[00m" ; fi | |
output="$output $2" | |
echo -en "$output" | |
} | |
cout() { | |
if [ "$1" == "action" ] ; then output="\e[01;32m[>]\e[00m" ; fi | |
if [ "$1" == "info" ] ; then output="\e[01;33m[i]\e[00m" ; fi | |
if [ "$1" == "error" ] ; then output="\e[01;31m[!]\e[00m" ; fi | |
output="$output $2" | |
echo -e "$output" | |
} | |
function checkRoot() | |
{ | |
if [[ $(whoami) != "root" ]]; then | |
cout error "You don't have root privilege!" | |
cout action "Quiting..." | |
sleep 2 | |
exit 1 | |
fi | |
} | |
function checkCurrentKernel() | |
{ | |
cout action "Checking your current kernel version..." | |
sleep 1 | |
cout info "You current kernel version is $currentKernel" | |
sleep 1 | |
} | |
function checkLatestKernel() | |
{ | |
cout action "Checking available latest kernel on kernel.org..." | |
sleep 1 | |
cout info "Latest kernel version is $latestKernel" | |
sleep 1 | |
} | |
function getURL() | |
{ | |
cout action "Finding download link..." | |
sleep 1 | |
cout info "Found download link at $urlLatestKernel" | |
sleep 1 | |
} | |
checkRoot | |
checkCurrentKernel | |
checkLatestKernel | |
getURL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment