
#!/bin/sh
# File	: chk_procmail-log.sh
# By	: Maarten.deBoer@Atos.net, 200318
# Subject	: Script to check procmail-log for "Permission" errors
PGM="`basename $0|cut -d\. -f1`"
VER="0.1"
TMP="/tmp/${PGM}.$$"
MAILTO="maarten.deboer@atos.net"

PROCMAILLOG="${HOME}/log/procmail.log"
ERRSTR="Permission denied"

echo "`date` ${PGM} v${VER} Started."

ANSW=`tail -10 ${PROCMAILLOG}|grep "${ERRSTR}"`
if [ "${ANSW}" != "" ]; then
  echo "`date` ${PGM} v${VER}: ERR (${ERRSTR}) found in LOG (${PROCMAILLOG})."|tee -a ${LOG}
  echo "  Running: /sbin/setenforce Permissive"|tee -a ${LOG}
  sudo /sbin/setenforce Permissive 
  echo "  Ran: /sbin/setenforce Permissive. Because of ERR (${ERRSTR}) found in LOG (${PROCMAILLOG})"|mailx -s "${PGM} v${VER}" ${MAILTO}
fi


echo "`date` ${PGM} v${VER} Finished."
exit 0

