#!/bin/sh
# (oe 20050101) only try to send mails if hylafax is configured
# to run in current runlevel and is indeed running.
# RUNLEVEL and RUNME are ideas taken from trustix.

RUNLEVEL=`runlevel|awk '{ print $2 }'`
RUNME=`chkconfig --list hylafax-server|grep ${RUNLEVEL}:on`
PID=`pidof hfaxd`

if [ x"${RUNME}" != x ] && ! [ -z "${PID}" ]; then
    /usr/sbin/faxcron | mail faxmaster
    exit 0
fi
