summaryrefslogtreecommitdiff
path: root/bin/updatekernel.sh
blob: ac2b5791a02402d18e60cd17d024405441c49934 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
### run: sh updatekernel.sh

#download amd64|i386
DownInstall() { wget $(lynx -dump -listonly $link | egrep 'all|'$@ ) ; echo dpkg -i *.deb ; }

link=$(lynx --dump http://kernel.ubuntu.com/~kernel-ppa/mainline/ | awk '/http/{print $2}'  | grep -v rc | tail -n 1)
KVERSION=$(echo $link | cut -d "/" -f 6)

LastKernelInstalled=$(ls /boot/ | grep img | cut -d "-" -f2 | tail -n 1)
LastKernelAvaliable=$(echo $KVERSION | sed -e "s/v//g"  | cut -d "-" -f1 )
LastKernelRC=$(lynx --dump http://kernel.ubuntu.com/~kernel-ppa/mainline/ | awk '/http/{print $2}'  | grep rc | tail -n 1 | cut -d "/" -f 6)

echo "\n\n\t\t[UBUNTU KERNELS] \
\n\n\tLast installed :\t $LastKernelInstalled \
\n\tLast Stable online :\t $LastKernelAvaliable
\n\tLast RC online :\t $LastKernelRC"


if [ $LastKernelInstalled = $LastKernelAvaliable ]  
   then echo  "\n\n\t already updated to version" $KVERSION  "\n\n" # non serve "echo -e"
	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
echo "/n/n"

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
dpkg -i *.deb
apt-get install -f
rm -Rf $DownloadFolder