#!/bin/sh
#
#
# smt-gen-report
# This script generate a new report for the SMT service.
# It syncs subscriptions and registrations from NCC to the local SMT 
# generate a report and send it via email

PATH="/sbin:/usr/sbin:/usr/bin:/bin"
SMTCMD=/usr/sbin/smt
. /etc/smt.d/smt-cron.conf

while read line ; do
    case "$line" in
    \#*|"") continue ;;
    esac
    eval val=${line#*=}
    case "$line" in
    PROXY_ENABLED=*)
        PROXY_ENABLED="${val}"
        ;;
    HTTP_PROXY=*)
        test -n "$val" || continue
        http_proxy="${val}"
        export http_proxy
        ;;
    HTTPS_PROXY=*)
        test -n "$val" || continue
        https_proxy="${val}"
        export https_proxy
        ;;
        esac
done < /etc/sysconfig/proxy
unset sys line val

if test "$PROXY_ENABLED" != "yes" ; then
    unset http_proxy https_proxy
fi
unset PROXY_ENABLED


if [ -x ${SMTCMD}-report ]
then
    ${SMTCMD}-report ${REPORT_PARAMS}
else
    echo "WARNING: Could not find the SMT binary ${SMTCMD}-report"
    echo "         Please make sure SMT is properly installed."
fi

# in cronjobs always do an exit 0 - even on errors - exit 1 only in case of real panic
exit 0



