#!/bin/bash
# Well, this test isn't quite living up to its name, but it does handle
# S.M.A.R.T. data.

if [ -z "$*" ] ; then echo no drives found ; exit 2 ; fi
smartctl=smartctl

while true ; do
	sleep 300
	for i in $* ; do {
		$smartctl -c /dev/$i | grep -qE '(S.M.A.R.T. Passed)|(S.M.A.R.T. Sense: Okay!)'
		if [ $? != 0 ] ; then {
			echo "Drive Failure Detected/Predicted: $i"
			$smartctl -c /dev/$i
			$smartctl -v /dev/$i
			$smartctl -L /dev/$i
			exit 1
		} ; fi
	} ; done
done
