#! /bin/sh
# aoe-version - display versions of AoE-related software
# Copyright 2008, Coraid, Inc., and licensed under GPL v.2.

aoetools=23

# 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 | 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
