Hello all, On Thu, Apr 12, 2012 at 06:24:15PM +0000, Bernhard Schmidt wrote: > [...] > Fortunately there is /proc/version ... > > Thanks for everyone involved, I'm off writing checkscripts.
FWIW, please check the attached script. HTH, Flo
#!/usr/bin/perl -w # fe: ripped out from # # apt-dater - terminal-based remote package update manager # # $Id: apt-dater-host 352 2009-05-19 15:55:49Z liske $ # # Authors: # Andre Ellguth <ellg...@ibh.de> # Thomas Liske <li...@ibh.de> # # Copyright Holder: # 2008-2009 (C) IBH IT-Service GmbH [http://www.ibh.de/apt-dater/] # # License: # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this package; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # use strict; my $CMD = shift; $ENV{'LC_ALL'} = 'C'; my $exitcode = &do_kernel; exit $exitcode; sub do_kernel() { my $UNKNOWN = 3; my $infostr = 'KERNELINFO: Installed'; my $verfile = '/proc/version'; my $version = `uname -r`; chomp($version); unless(-r $verfile) { print "$infostr $version, but could not read $verfile\n"; return $UNKNOWN; } $verfile = `cat $verfile`; chomp($verfile); unless($verfile =~ /^\S+ \S+ \S+ \(Debian ([^\)]+)\)/) { print "$infostr $version, but no comparison possible against apparent non-Debian kernel $verfile\n"; return $UNKNOWN; } my $vers = $1; print "$infostr $vers"; my $reboot = 0; open(HDPKG, "dpkg-query -W -f='\${Version} \${Status;20} \${Maintainer} \${Provides}\n' 'linux-image*'|grep 'install ok installed Debian Kernel Team'|grep linux-image|") or die "Could not fork: $!\n"; while(<HDPKG>) { next unless (/^(\S+)\s/); unless (system("dpkg", "--compare-versions", $vers, "lt", $1) >> 8) { $reboot = 1; print ", available: $1"; } } close(HDPKG); print "\n"; return $reboot; }