#!/bin/sh
#
DNEWS=/usr/local/dnews

$DNEWS/tellnews status >/dev/null
if [ $? -eq 0 ] ; then exit 0; fi

PID=`ps -fu news | grep dnews | awk '{ print $2 }' | xargs echo`
if [ -n "$PID" ] ; then
     sleep 5
     $DNEWS/tellnews status
     if [ $? -eq 0 ] ; then exit 0; fi
fi

cd $DNEWS
tail -2000 dnews.log >last.log
mail <last.log chrisp@netwin.co.nz -s "crashlog" 
$DNEWS/dnews_start.sh
$DNEWS/tellnews status

# end

