diff options
-rw-r--r-- | check-kernel.in | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/check-kernel.in b/check-kernel.in index 2354345..1113b75 100644 --- a/check-kernel.in +++ b/check-kernel.in @@ -47,7 +47,6 @@ while true; do shift done - if which pacman >/dev/null 2>&1; then # arch linux running=$( @@ -66,11 +65,12 @@ elif which apt >/dev/null 2>&1; then uname -r ) installed=$( - dpkg-query -W 'linux-image-*-?86' | \ + dpkg-query -W 'linux-image-*' | \ cut -f1 | \ sed ' s|^linux-image-|| ' | \ + grep -x '\([0-9.]\+-\)\{2\}[^-]\+' | \ sort -V | \ tail -n1 ) @@ -80,12 +80,22 @@ else fi if [ "${running}" = "${installed}" ]; then - >&2 printf 'The installed kernel (%s) is currently running.\n' \ - "${installed}" + if ! ${reboot}; then + >&2 printf 'The installed kernel (%s) is currently running.\n' \ + "${installed}" + fi exit 0 else >&2 printf 'The installed (%s) and running kernel (%s) differ.\n' \ "${installed}" \ "${running}" - exit 1 + if ${reboot}; then + >&2 printf 'Press enter to reboot ...' + read s + if [ -z "${s}" ]; then + reboot + fi + else + exit 1 + fi fi |