#!/bin/sh
CORE_FILES_DIR=/core_files
MNT_DIR=/mnt

# we don't care if the total core files amounts to less that 5 K bytes
# LOWER_LIMIT will set this limit under with we don't care to report
LOWER_LIMIT=5

# First, if there is note CORE_FIELS_DIR then we are done :-)
if [ ! -d ${CORE_FILES_DIR} ]
then
	exit
fi
# let us figure out how much core files are occupying...
ROOTkbytes=`/usr/bin/du -sk ${CORE_FILES_DIR} | cut -f1`
MNTkbytes=`/usr/bin/du -sk ${MNT_DIR}/${CORE_FILES_DIR} | cut -f1`
kbytes=`expr ${ROOTkbytes} + ${MNTkbytes}`
ROOTnumberOfCoreFiles=`/usr/bin/find /${CORE_FILES_DIR}/ -name "*core*" -type f -print | \
wc -l | sed -e's/[ 	]//g'`
MNTnumberOfCoreFiles=`/usr/bin/find ${MNT_DIR}/${CORE_FILES_DIR}/ -name "*core*" -type f -print | \
wc -l | sed -e's/[ 	]//g'`
numberOfCoreFiles=`expr ${ROOTnumberOfCoreFiles} + ${MNTnumberOfCoreFiles}`
if [ ${numberOfCoreFiles} -ge 1 ]
then
	printf "


**************** CORE FILES WARNING ********************************
|                                                                  |
|       Core files directory    : %-20s             |
|       Number of files found   : %-20s             |
|       Total size occupied     : %8s Kilobytes               |
|                                                                  |
|       Please run the command \"savecore\" to remove/ftp them.      |
|       This message will repeat at the top of every hour          |
|       until the core files are removed.  - Thanks.               |
|                                                                  |
|*******************************************************************


" ${CORE_FILES_DIR} ${numberOfCoreFiles} ${kbytes} > /dev/console
fi
