#!/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`
$OFWTKPATH/bin/get_today > /tmp/today_log
echo >> /tmp/today_log

(echo "From: \"Firewall report and notification service\" <root@$fqdnhost>";
 echo "Subject: $host daily traffic report";
 echo ;
 $OFWTKPATH/bin/chart.pl -d -f /tmp/today_log ) | $OFWTKPATH/bin/ssmtp $ADMIN

(echo "From: \"Firewall report and notification service\" <root@$fqdnhost>";
 echo "Subject: $host daily network services usage report";
 echo ;
 $OFWTKPATH/bin/summ_complete.pl /tmp/today_log ) | $OFWTKPATH/bin/ssmtp $ADMIN

(echo "From: \"Firewall report and notification service\" <root@$fqdnhost>";
 echo "Subject: $host daily network resources usage report";
 echo ;
 $OFWTKPATH/bin/summ_resources.sh < /tmp/today_log  ) | $OFWTKPATH/bin/ssmtp $ADMIN

rm /tmp/today_log
