| Author |
Message |
ibgb
|
|
Post subject: Script to show installed and latest available kernels
Posted: 20.09.2010, 03:38
|
|
Joined: 2010-09-11
Posts: 42
Status: Offline
|
|
On a couple systems I have, I don't have the kernel meta-package installed and I update kernels manually.
I threw together this script a while ago to show me my installed and latest available kernels. It's nothing fancy but it does what I want it to.
Since there was a request for something like it posted in another thread, I figured I'd put this up here in case someone might be able to use it.
Just put it somewhere, make it executable, and run it as user. If you want to do an apt-get update (and you should unless you know you're current), you can do it through a prompt while running the script.
Code:
#! /bin/bash
# Script to show installed and available kernels in
# an aptosid system
printf "\n Do you want to run 'apt-get update' first\n (to make sure the latest kernel info is current)?\n\n Enter "Y" for yes or "n" for no " && read yn
case $yn in
Y|y)
su-to-root -c 'apt-get update' || exit 2
;;
N|n)
:
;;
*)
printf "\n BAD CHOICE!\n\n" && exit 1
;;
esac
printf "\nGathering information..."
crntkern=$(uname -r)
latkern=$(apt-cache search ^linux-image slh | cut -f1 -d" " | sort -V | tail -1 | sed 's|linux-image-||')
instkern=$(find /boot/ -maxdepth 1 -type f -name vmlinuz* | sed 's|/boot/vmlinuz-||' | egrep -v "$crntkern")
arrange=$(for i in ${instkern};do
printf "\t\t $i\n"
done)
printf "\n\n The latest available kernel is:\n\t\t $latkern\n\n The currently running kernel is:\n\t\t $crntkern\n\n Other installed kernels are:\n $arrange\n\n"
exit 0
edit: changed "sort -n" to "sort -V" in $latkern variable to fix dumb mistake |
Last edited by ibgb on 20.09.2010, 18:27; edited 1 time in total
|
| |
|
|
|
 |
|
|
Post subject: RE: Script to show installed and latest available kernels
Posted: 20.09.2010, 08:00
|
|
Moderator

Joined: 2010-09-11
Posts: 464
|
|
I have much simpler script for myself
Quote:
echo "apt-get install \\"
apt-cache depends linux-image-2.6-aptosid-amd64 | awk '/ Depends/ { print $2 " \\" }'
apt-cache depends linux-headers-2.6-aptosid-amd64 | awk '/ Depends/ { print $2 }'
or for i686 version
Quote:
echo "apt-get install \\"
apt-cache depends linux-image-2.6-aptosid-i686 | awk '/ Depends/ { print $2 " \\" }'
apt-cache depends linux-headers-2.6-aptosid-i686 | awk '/ Depends/ { print $2 }'
It generate the apt-get command to install the current version.
(redirect the out put to new script and call it with shell)
current installed version of kernel can be seen in uname -u, so it's easy for me to
decide if I want to install the new or not.
Officially recommended way is having meta-packages installed and automatically install
new kernel packages at d-u. I'm posting this above for this User script forum only. |
|
|
| |
|
|
|
 |
Mte90
|
|
Post subject: RE: Script to show installed and latest available kernels
Posted: 20.09.2010, 09:10
|
|

Joined: 2010-09-14
Posts: 51
Location: Rieti
Status: Offline
|
|
but an autoremover or a script that remove the oldest kernel installed after the installation of a new?
sorry for my english |
_________________ I'm an italian Aptosid user!!
|
| |
|
|
|
 |
|
|
Post subject: Re: RE: Script to show installed and latest available kernel
Posted: 20.09.2010, 10:19
|
|
Moderator

Joined: 2010-09-11
Posts: 464
|
|
|
Mte90 wrote:
but an autoremover or a script that remove the oldest kernel installed after the installation of a new?
sorry for my english
Installation of new kernel should not remove already installed kernel.
Simply because new kernel may not work, or some devices or programs may be incompatible with the new kernel.
So, it's the administrator's (yours, for your PC) task to decide which old kernels to be removed. |
|
|
| |
|
|
|
 |
se7en
|
|
Post subject: RE: Re: RE: Script to show installed and latest available ke
Posted: 20.09.2010, 10:39
|
|

Joined: 2010-09-11
Posts: 164
Status: Offline
|
|
I think Mte90 asks. if there is a script to remove old kernel.
kernel-remover is the script but like muchan said you should always keep at least 1 older besides the new one. Just in case the new one doesn't work. |
_________________ Don't mention the war!
Meine Meinung steht fest! Bitte verwirren Sie mich nicht mit Tatsachen!
|
| |
|
|
|
 |
Mte90
|
|
Post subject: RE: Re: RE: Script to show installed and latest available ke
Posted: 20.09.2010, 12:09
|
|

Joined: 2010-09-14
Posts: 51
Location: Rieti
Status: Offline
|
|
It is like se7en says. I have always two versions of the kernel when I install a new version remove the oldest with kernel-remover.
If you could automate it install the new kernel and remove the old one is more practical. |
_________________ I'm an italian Aptosid user!!
|
| |
|
|
|
 |
blackhole
|
|
Post subject: RE: Re: RE: Script to show installed and latest available ke
Posted: 20.09.2010, 13:08
|
|

Joined: 2010-09-12
Posts: 110
Status: Offline
|
|
I checked the script but it is not giving me the latest kernel:
Quote:
The latest available kernel is:
2.6.35-4.slh.6-aptosid-amd64
The currently running kernel is:
2.6.35-4.slh.15-aptosid-amd64
Other installed kernels are:
2.6.34-0.slh.11-sidux-amd64
2.6.35-4.slh.6-aptosid-amd64
|
|
|
| |
|
|
|
 |
cleary
|
|
Post subject: Re: RE: Re: RE: Script to show installed and latest availabl
Posted: 20.09.2010, 13:15
|
|

Joined: 2010-08-27
Posts: 34
Status: Offline
|
|
|
blackhole wrote:
I checked the script but it is not giving me the latest kernel:
Quote:
The latest available kernel is:
2.6.35-4.slh.6-aptosid-amd64
The currently running kernel is:
2.6.35-4.slh.15-aptosid-amd64
Other installed kernels are:
2.6.34-0.slh.11-sidux-amd64
2.6.35-4.slh.6-aptosid-amd64
I think it's a bug related to the use of the sort function...
2.6.35-4.slh.6 > 2.6.35-4.slh.1(5-aptosid-amd64) |
|
|
| |
|
|
|
 |
ibgb
|
|
Post subject: RE: Re: RE: Re: RE: Script to show installed and latest avai
Posted: 20.09.2010, 18:27
|
|
Joined: 2010-09-11
Posts: 42
Status: Offline
|
|
blackhole
I forgot that when you put a script out there for others to use it's SUPPOSED TO WORK RIGHT!
Sorry.
cleary is of course correct in pointing to my sort as the culprit. The -n option won't work here. But the -V option seems made for it and I should have used it from the beginning. It works perfectly in some quick testing I did with it.
The posted script has been updated.
Thanks to you for pointing out the problem and to cleary for pointing to the source of it. |
|
|
| |
|
|
|
 |
blackhole
|
|
Post subject: RE: Re: RE: Re: RE: Script to show installed and latest avai
Posted: 21.09.2010, 13:12
|
|

Joined: 2010-09-12
Posts: 110
Status: Offline
|
|
However, I have something very simple for doing what sidux hermes was doing:
Quote:
apt-get update; apt-cache search aptosid-amd64; apt-get -d dist-upgrade
You can put this text in a "link to application" for easy launch. |
|
|
| |
|
|
|
 |
|
|