From daf87b002dd871d7d369539d9126b7d9e99b204a Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Tue, 19 Dec 2017 08:51:13 +0100 Subject: Initial commit --- check-kernel | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 check-kernel diff --git a/check-kernel b/check-kernel new file mode 100755 index 0000000..5370f49 --- /dev/null +++ b/check-kernel @@ -0,0 +1,43 @@ +#!/bin/sh + +if which pacman >/dev/null 2>&1; then + # arch linux + running=$( + uname -r | \ + sed ' + s|-ARCH$|| + ' + ) + installed=$( + pacman -Q linux | \ + cut -d' ' -f2 + ) +elif which apt >/dev/null 2>&1; then + # debian + running=$( + uname -r + ) + installed=$( + dpkg-query -W 'linux-image-*-?86' | \ + cut -f1 | \ + sed ' + s|^linux-image-|| + ' | \ + sort -V | \ + tail -n1 + ) +else + >&2 printf 'Cannot determin installed kernel.\n' + exit 2 +fi + +if [ "${running}" = "${installed}" ]; then + >&2 printf 'The installed kernel (%s) is currently running.\n' \ + "${installed}" + exit 0 +else + >&2 printf 'The installed (%s) and running kernel (%s) differ.\n' \ + "${installed}" \ + "${running}" + exit 1 +fi -- cgit v1.2.3-70-g09d2