##/bin/sh

#check bonnie is installed
if [ "`whereis bonnie++`" == "bonnie++:"]; then
        echo $0 error bonnie not installed.
        exit
fi

run_bonnie()
{
	# dir, no hostname, quiet, fast (no per-char), ram (no sz checks)
	tmp=/var/tmp

	mkdir ./bonnie || exit 1
	defaults="-d ./bonnie -q -f -r 0"
	defaults="$defaults -u "`id -u`" -g "`id -g`
	bonnie++ -m '' $defaults $@ >$tmp/$$.bonnie.stdout 2>$tmp/$$.bonnie.stderr
	status=$?
	rm -fr ./bonnie
	[ $status -ne 0 ] && exit 1
	filter_stdout < $tmp/$$.bonnie.stdout
	filter_stderr < $tmp/$$.bonnie.stderr 1>&2
	rm -f $tmp/$$.bonnie.stdout $tmp/$$.bonnie.stderr
	exit 0
}
