Created
October 9, 2016 10:00
-
-
Save kunev/616d258f25cb0f4c55bac1678099204d to your computer and use it in GitHub Desktop.
check if currently running kernel version matches the installed linux package version
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function currently_installed_kernel() { | |
yaourt -Qi linux | egrep '^Version\s+:\s+.+$' | sed -e 's/Version\s\+:\s\+//' | |
} | |
function currently_running_kernel() { | |
uname -a | grep -P '\S+(?=-ARCH)' -o | |
} | |
installed=$(currently_installed_kernel) | |
running=$(currently_running_kernel) | |
if [ "$running" == "$installed" ]; then | |
echo "Running kernel version matches installed linux package version" | |
exit 0 | |
else | |
echo "Running kernel version differs from installed linux package version" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment