blob: 2354345e064795d52a6daed5d90e65d202f6649a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#!/bin/sh
# check-kernel #VERSION#
verwendung() {
>&2 echo 'check-kernel checks if the installed kernel is currently running'
>&2 echo ''
>&2 echo 'Usage: sendmailadvanced [OPTIONS]'
>&2 echo ' -r,--reboot reboot system if installed kernel is not yet running'
>&2 echo \
'#HELPTEXT# #'
exit 1
}
eval set -- "$(
getopt -o eh:i:st \
--long encrypt \
--long help \
--long version \
-n "$(basename "$0")" -- "$@" \
|| echo verwendung
)"
reboot=false
while true; do
case "$1" in
-r|--reboot)
shift
reboot=true
;;
--help)
verwendung 0
;;
--version)
echo '#VERSION#'
exit 0
;;
--)
shift
break
;;
*)
>&2 echo "FEHLER: Verstehe Option \"$1\" doch nicht! Ich beende."
verwendung
;;
esac
shift
done
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
|