aoe-version 1.6 KB

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