#!/bin/sh
# Check local hds.
# For use with crontab every day. (nobodyo<nospam>@</nospam>web.de)

# for debugging/verbosity
#set -x

# integer i 
typeset -i i=0 

# To  test  within the shell for whether or not the different bits are turned
# on or off, you can use the following type of construction (this is bash syntax):
# smartstat=$(($? & 8)).

for FILE in /dev/sda; do
  smartctl -a $FILE 2>&1 > smartctl.out
  i=$?
  # check if the return status is > 0
  if [ $i -gt 0 ];
    then
      echo "$FILE: return status of smartctl -a: $i"
      mail -s "return status of smartctl: $i" rf0@localhost < smartctl.out ;
  fi
done

exit $i

