#!/bin/bash
TMPFILE=/tmp/oprhan.result
MYTHCONFDIR=/usr/share/mythtv /usr/LH/bin/find_orphans.py --printonly > $TMPFILE


COLUMN=orphan    # Name of the column
COLOR=green      # By default, everything is OK
MSG="All OK"




#yellow
for i in "Orphaned video files" "Orphaned snapshots" "Database backups" "Other files"
do
   grep -q  "$i" $TMPFILE
   status=$?
   if [ $status -eq 0 ]
   then
       COLOR="yellow"
       MSG="Problems found"
   fi
done

#red
for i in "Recordings with missing files" "Zero byte recordings"
do
   grep -q  "$i" $TMPFILE
   status=$?
   if [ $status -eq 0 ]
   then
       COLOR="red"
       MSG="Problems found"
   fi
done

MSG="
    ${MSG}
    `cat $TMPFILE` "
# Tell Hobbit about it
$BB $BBDISP "status $MACHINE.$COLUMN $COLOR `date`
   ${MSG}
   " 
exit 0