diff options
author | Holger Levsen <holger@layer-acht.org> | 2015-11-27 13:55:06 +0100 |
---|---|---|
committer | Holger Levsen <holger@layer-acht.org> | 2015-11-27 13:55:06 +0100 |
commit | c8b3d6c07b21cabcdd300ec491564c24ae516c30 (patch) | |
tree | 3bb020a4e15f744d113ab046bb04e02ff5097ef4 /hosts/odxu4-armhf-rb/usr/local/bin/dsa-check-running-kernel | |
parent | d2ed20984c0550baf084ee7fef5b64de3661b1e6 (diff) | |
download | jenkins.debian.net-c8b3d6c07b21cabcdd300ec491564c24ae516c30.tar.xz |
updated to ba573051 from git://anonscm.debian.org/mirror/dsa-nagios.git - thanks DSA
Diffstat (limited to 'hosts/odxu4-armhf-rb/usr/local/bin/dsa-check-running-kernel')
-rwxr-xr-x | hosts/odxu4-armhf-rb/usr/local/bin/dsa-check-running-kernel | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/hosts/odxu4-armhf-rb/usr/local/bin/dsa-check-running-kernel b/hosts/odxu4-armhf-rb/usr/local/bin/dsa-check-running-kernel index 11574804..80f45bfb 100755 --- a/hosts/odxu4-armhf-rb/usr/local/bin/dsa-check-running-kernel +++ b/hosts/odxu4-armhf-rb/usr/local/bin/dsa-check-running-kernel @@ -3,7 +3,7 @@ # Check if the running kernel has the same version string as the on-disk # kernel image. -# Copyright 2008,2009,2011 Peter Palfrader +# Copyright 2008,2009,2011,2012,2013,2014 Peter Palfrader # Copyright 2009 Stephen Gran # Copyright 2010,2012,2013 Uli Martens # Copyright 2011 Alexander Reichle-Schmehl @@ -37,13 +37,13 @@ get_offset() { file="$1" needle="$2" + perl -e ' undef $/; - $i = index(<>, "'"$needle"'"); - if ($i < 0) { - exit 1; - }; - print $i,"\n"' < "$file" + $i = 0; $k=<>; + while (($i = index($k, "'"$needle"'", $i)) >= 0) { + print $i++,"\n"; + }; ' < "$file" } get_avail() { @@ -58,7 +58,7 @@ get_avail() { # DSA uses kernel versions of the form 2.6.29.3-dsa-dl380-oldxeon, where # Debian uses versions of the form 2.6.29-2-amd64 if [ "${kervers#3}" != "$kervers" ]; then - metavers=$(echo $kervers | sed -r -e 's/^3\.[0-9].[0-9]+-[A-Za-z0-9\.]+-(.*)/\1/') + metavers=$(echo $kervers | sed -r -e 's/^3\.[0-9]+(\.[0-9])?+-[A-Za-z0-9\.]+-(.*)/\2/') elif [ "${kervers//dsa}" != "$kervers" ]; then metavers=$(echo $kervers | sed -r -e 's/^2\.(4|6)\.[0-9]+([\.0-9]+?)-(.*)/2.\1-\3/') else @@ -129,13 +129,12 @@ cat_vmlinux() { filter="$3" hdroff="$4" - off=`get_offset "$image" $header` - if [ "$?" != 0 ]; then - # not found, exit - return 1 - fi - - (dd ibs="$((off+$hdroff))" skip=1 count=0 && dd bs=512k) < "$image" 2>/dev/null | $filter 2>/dev/null + get_offset "$image" $header | head -n 5 | while read off; do + (if [ "$off" != 0 ]; then + dd ibs="$((off+hdroff))" skip=1 count=0 + fi && + dd bs=512k) < "$image" 2>/dev/null | $filter 2>/dev/null + done } get_image_linux() { @@ -144,13 +143,13 @@ get_image_linux() { image="$1" # gzip compressed image - if cat_vmlinux "$image" "\x1f\x8b\x08\x00" "zcat" 0; then return; fi - if cat_vmlinux "$image" "\x1f\x8b\x08\x08" "zcat" 0; then return; fi + cat_vmlinux "$image" "\x1f\x8b\x08\x00" "zcat" 0 + cat_vmlinux "$image" "\x1f\x8b\x08\x08" "zcat" 0 # lzma compressed image - if cat_vmlinux "$image" "\x00\x00\x00\x02\xff" "xzcat" -1; then return; fi - if cat_vmlinux "$image" "\x00\x00\x00\x04\xff" "xzcat" -1; then return; fi + cat_vmlinux "$image" "\x00\x00\x00\x02\xff" "xzcat" -1 + cat_vmlinux "$image" "\x00\x00\x00\x04\xff" "xzcat" -1 # xz compressed image - if cat_vmlinux "$image" "\xfd\x37\x7a\x58\x5a " "xzcat" 0; then return; fi + cat_vmlinux "$image" "\xfd\x37\x7a\x58\x5a " "xzcat" 0 echo "ERROR: Unable to extract kernel image." 2>&1 exit 1 @@ -163,9 +162,9 @@ freebsd_check_running_version() { local r="$(uname -r)" local v="$(uname -v| sed -e 's/^#[0-9]*/&:/')" - local q='@\(#\)FreeBSD '"$r $v" + local q='@(#)FreeBSD '"$r $v" - if zcat "$imagefile" | $STRINGS | egrep -q "$q"; then + if zcat "$imagefile" | $STRINGS | grep -F -q "$q"; then echo "OK" else echo "not OK" |