24ebbd
#! /bin/sh
24ebbd
24ebbd
# Send mail
24ebbd
if which mail >/dev/null 2>&1
24ebbd
then
24ebbd
  echo "$SMARTD_MESSAGE" | mail -s "$SMARTD_FAILTYPE" "$SMARTD_ADDRESS"
24ebbd
fi
24ebbd
24ebbd
# Notify desktop user
24ebbd
MESSAGE="SMART Disk monitor:"
24ebbd
case "$SMARTD_FAILTYPE" in
24ebbd
    "EmailTest"|"Health"|"Temperature"|"Usage")
24ebbd
        ;;
24ebbd
    *)
24ebbd
#       "CurrentPendingSector",       // 10
24ebbd
#       "OfflineUncorrectableSector", // 11
24ebbd
#       "FailedReadSmartErrorLog",    // 7
24ebbd
#       "ErrorCount",                 // 4
24ebbd
#       "FailedReadSmartData",        // 6
24ebbd
#       "FailedHealthCheck",          // 5
24ebbd
#       "FailedOpenDevice",           // 9
24ebbd
#       "SelfTest",                   // 3
24ebbd
#       "FailedReadSmartSelfTestLog", // 8
24ebbd
      exit 0
24ebbd
esac
24ebbd
24ebbd
# direct write to terminals, do not use 'wall', because we don't want its ugly header
24ebbd
for t in $(who | awk '{ print $2; }' | grep -e '^tty' -e '^pts/')
24ebbd
do
24ebbd
  echo "$MESSAGE
24ebbd
$SMARTD_MESSAGE" >/dev/$t 2>/dev/null ||:
24ebbd
done
24ebbd