#!/bin/sh # # CONFIG # dir='/var/run/smart-check' get='/root/smart/status.sh' # # MAIN # # dir has to exist mkdir -p "$dir" # file names old="$dir/current" new="$dir/new" # generate files touch "$old" $get >"$new" # compare diff=`diff -q "$old" "$new"` if [ -n "$diff" ] then echo echo "The S.M.A.R.T. indicates a change in the health of one of your hard drives" echo echo "New state:" cat "$new" | sed 's/^/ /' echo echo "Old state:" cat "$old" | sed 's/^/ /' echo fi # replace files rm "$old" mv "$new" "$old"