forked from OpenAoE/aoetools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aoe-version
53 lines (48 loc) · 1.63 KB
/
aoe-version
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
#! /bin/sh
# aoe-version - display versions of AoE-related software
# Copyright 2013, CORAID, Inc., and licensed under GPL v.2.
aoetools=36
# modinfo doesn't always work correctly when there is a file
# in the current working directory called "aoe", but it's
# not hard to change the current working directory.
for wd in . / /sys /var/run /usr /proc /etc /home; do
a=`{ cd "$wd" 2> /dev/null && test ! -r aoe && echo yes; } || echo no`
if test "$a" = "yes"; then
cd "$wd"
break
fi
done
# The aoe module isn't guaranteed to be in the location below,
# but if we only try to use it when each of the directories
# above was not usable, we shouldn't use the hard-coded location
# often.
aoe=aoe
if test -r ./aoe; then
aoe="/lib/modules/`uname -r`/kernel/drivers/block/aoe/aoe.ko"
fi
# standalone aoe drivers have a module parameter "version"
installed="`modinfo \"$aoe\" 2>/dev/null | awk '/srcversion/ {next} /^parm:.*version:aoe module/ {print $NF; exit 0}'`"
if test -z "$installed"; then
# Recent kernels have a "version" of their own, so
# they didn't want our module parameter, so we look
# for that, too, in case user is using kernel.org driver.
installed="`modinfo \"$aoe\" 2>/dev/null | awk '/^version:/ {print $NF; exit 0}'`"
fi
if test "$?" != "0" || test -z "$installed"; then
installed="(unknown)"
fi
if test -d /sys/module/aoe; then
running="`find /sys/module/aoe -name version | sed 1q | xargs cat`"
if test "$?" != "0"; then
running="(unknown)"
fi
else
running="(none)"
fi
while read val desc; do
printf "%22s:\t%s\n" "$desc" "$val"
done <<EOF
$aoetools aoetools
$installed installed aoe driver
$running running aoe driver
EOF