Debian Codegraph @

aoe-version

raw
1 #! /bin/sh
2 # aoe-version - display versions of AoE-related software
3 # Copyright 2013, CORAID, Inc., and licensed under GPL v.2.
4
5 aoetools=36
6
7 # modinfo doesn't always work correctly when there is a file
8 # in the current working directory called "aoe", but it's
9 # not hard to change the current working directory.
10 for wd in . / /sys /var/run /usr /proc /etc /home; do
11 a=`{ cd "$wd" 2> /dev/null && test ! -r aoe && echo yes; } || echo no`
12 if test "$a" = "yes"; then
13 cd "$wd"
14 break
15 fi
16 done
17 # The aoe module isn't guaranteed to be in the location below,
18 # but if we only try to use it when each of the directories
19 # above was not usable, we shouldn't use the hard-coded location
20 # often.
21 aoe=aoe
22 if test -r ./aoe; then
23 aoe="/lib/modules/`uname -r`/kernel/drivers/block/aoe/aoe.ko"
24 fi
25
26 # standalone aoe drivers have a module parameter "version"
27 installed="`modinfo \"$aoe\" 2>/dev/null | awk '/srcversion/ {next} /^parm:.*version:aoe module/ {print $NF; exit 0}'`"
28 if test -z "$installed"; then
29 # Recent kernels have a "version" of their own, so
30 # they didn't want our module parameter, so we look
31 # for that, too, in case user is using kernel.org driver.
32 installed="`modinfo \"$aoe\" 2>/dev/null | awk '/^version:/ {print $NF; exit 0}'`"
33 fi
34 if test "$?" != "0" || test -z "$installed"; then
35 installed="(unknown)"
36 fi
37
38 if test -d /sys/module/aoe; then
39 running="`find /sys/module/aoe -name version | sed 1q | xargs cat`"
40 if test "$?" != "0"; then
41 running="(unknown)"
42 fi
43 else
44 running="(none)"
45 fi
46
47 while read val desc; do
48 printf "%22s:\t%s\n" "$desc" "$val"
49 done <<EOF
50 $aoetools aoetools
51 $installed installed aoe driver
52 $running running aoe driver
53 EOF