#!/bin/sh
if [ ! -r /etc/openfwtk.conf ]; then
    echo "Error: /etc/openfwtk.conf file is not exist or access to it is denied" 1>&2
    exit 1
fi
. /etc/openfwtk.conf
if [ "$OFWTKPATH" = "" ]; then
    echo "Error: OFWTKPATH is empty" 1>&2
    exit 1
fi

ADMIN=`cat $OFWTKPATH/etc/admin`
host=`hostname -s`
fqdnhost=`hostname`

(echo "From: \"Firewall report and notification service\" <root@$fqdnhost>";
 echo "Subject: $host frequent check output";
 echo ;
 $OFWTKPATH/bin/logtail /var/log/messages $OFWTKPATH/var/logtail/frequent.status |
 $OFWTKPATH/bin/frequentcheck.sh ) > /tmp/frequent.$$ || 

	$OFWTKPATH/bin/ssmtp $ADMIN < /tmp/frequent.$$

rm /tmp/frequent.$$
