Last active
December 28, 2015 14:49
-
-
Save untergrundbiber/7517368 to your computer and use it in GitHub Desktop.
Ubuntu Kernel Update
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/dash | |
LastKernelInstalled=$(ls /boot/ | grep img | cut -d "-" -f2 | tail -n 1) | |
LastKernelStable=$(lynx --dump http://kernel.ubuntu.com/~kernel-ppa/mainline/ | awk '/http/{print $2}' | grep -v rc | tail -n 1 | cut -d "/" -f 6) | |
LastKernelRC=$(lynx --dump http://kernel.ubuntu.com/~kernel-ppa/mainline/ | awk '/http/{print $2}' | grep rc | tail -n 1 | cut -d "/" -f 6) | |
link_stable=$(lynx --dump http://kernel.ubuntu.com/~kernel-ppa/mainline/ | awk '/http/{print $2}' | grep -v rc | tail -n 1) | |
link_rc=$(lynx --dump http://kernel.ubuntu.com/~kernel-ppa/mainline/ | awk '/http/{print $2}' | grep rc | tail -n 1) | |
# Check for dependencies | |
check_deps () { | |
DEPS=$(echo {lynx}) | |
for i in $DEPS ; do | |
dpkg-query -W -f='${Package}\n' | grep ^$i$ > /dev/null | |
if [ $? = 0 ] ; then | |
echo "Installing deps ..." | |
aptitude install $i -y > /dev/null | |
fi | |
done | |
} | |
DownInstall() { wget $(lynx -dump -listonly $link | egrep 'all|'$@ | grep -Ev "lowlatency") ; } | |
install() { | |
DownloadFolder=$HOME/.kernel_update/kernel_$KVERSION | |
echo $DownloadFolder | |
mkdir -p $DownloadFolder | |
cd $DownloadFolder | |
#System architecture | |
arch=`uname -m` | |
if [ $arch = i686 ] || [ $arch = i386 ]; then | |
DownInstall i386 | |
elif [ $arch = "x86_64" ]; then | |
DownInstall amd64 | |
else | |
echo "Unsupported Architecture" | |
fi | |
echo "Install now?" | |
read -p "Press Enter to continue, or abort by pressing CTRL+C" nothing | |
dpkg -i *.deb | |
apt-get install -f | |
#rm -Rf $DownloadFolder | |
} | |
stable() { | |
link=$link_stable | |
KVERSION=$(echo $link | cut -d "/" -f 6) | |
if [ $LastKernelInstalled = $LastKernelStable ] | |
then echo "\n\n\t already updated to version" $KVERSION "\n\n" | |
exit | |
else echo "\n\n\t upgrading to version" $KVERSION "\n\n" | |
fi | |
echo "$(tput setaf 3)---kernel $KVERSION will be installed in an `uname -i` system---$(tput sgr0)" | |
sleep 2 | |
read -p "Press Enter to continue, or abort by pressing CTRL+C" nothing | |
install | |
} | |
rc() { | |
link=$link_rc | |
KVERSION=$(echo $link | cut -d "/" -f 6) | |
if [ $LastKernelInstalled = $LastKernelRC ] | |
then echo "\n\n\t already updated to version" $KVERSION "\n\n" | |
exit | |
else echo "\n\n\t upgrading to version" $KVERSION "\n\n" | |
fi | |
echo "$(tput setaf 3)---kernel $KVERSION will be installed in an `uname -i` system---$(tput sgr0)" | |
sleep 2 | |
read -p "Press Enter to continue, or abort by pressing CTRL+C" nothing | |
install | |
} | |
check_deps | |
echo "\n\n\t\t[UBUNTU KERNELS] \ | |
\n\n\tLast installed :\t $LastKernelInstalled \ | |
\n\tLast Stable online :\t $LastKernelStable | |
\n\tLast RC online :\t $LastKernelRC" | |
echo "Which version do you want to install?" | |
echo "1) Stable" | |
echo "2) RC" | |
read choice | |
case $choice in | |
1) | |
stable | |
;; | |
2) | |
rc | |
;; | |
*) | |
echo "Try again"; | |
echo "Press Enter to continue. . ." ; | |
read | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment