#!/bin/sh

# Get service config
[ -f /etc/sysconfig/chkrootkit ] && . /etc/sysconfig/chkrootkit

DATE=`date`
SYSTEM=`hostname`

cd /usr/bin
t=`mktemp ${TMPDIR:-/tmp}/chkrootkitXXXXXX` || exit 1
echo -n "Generated with: " > $t
/usr/bin/chkrootkit -V 2>> $t
/usr/bin/chkrootkit 2>&1 | /bin/egrep -v '(not (infected|found|promisc)|nothing (found|detected|deleted)|no suspect files|ROOTDIR is)' >> $t
L=$(wc -l $t)
if [ "${L% *}" -gt 1 ]; then
	mail -s "CHKROOTKIT $SYSTEM $DATE" $CHKROOTKIT_MAILTO < $t
fi
rm -f $t
