From 65e2c9e92c8ef52fc6d47348ddd1bf255e069701 Mon Sep 17 00:00:00 2001 From: Eugeni Dodonov Date: Fri, 26 Jun 2009 19:20:19 +0000 Subject: Simplified diff checks. --- cron-sh/functions.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'cron-sh/functions.sh') diff --git a/cron-sh/functions.sh b/cron-sh/functions.sh index e987d91..594d703 100644 --- a/cron-sh/functions.sh +++ b/cron-sh/functions.sh @@ -37,6 +37,24 @@ FILTER="\(`echo $EXCLUDEDIR | sed -e 's/ /\\\|/g'`\)" ### Functions ### +Diffcheck() { + TODAY="$1" + YESTERDAY="$2" + DIFF="$3" + MESSAGE="$4" + if [[ -f ${YESTERDAY} ]]; then + if ! diff -u ${YESTERDAY} ${TODAY} > ${DIFF}; then + printf "\nSecurity Warning: change in $MESSAGE found :\n" >> ${DIFF} + grep '^+' ${DIFF} | grep -vw "^+++ " | sed 's|^.||'|sed -e 's/%/%%/g' | while read file; do + printf "\t\t- Newly added $MESSAGE : ${file}\n" + done >> ${DIFF} + grep '^-' ${DIFF} | grep -vw "^--- " | sed 's|^.||'|sed -e 's/%/%%/g' | while read file; do + printf "\t\t- No longer present $MESSAGE : ${file}\n" + done >> ${DIFF} + fi + fi +} + Syslog() { if [[ ${SYSLOG_WARN} == yes ]]; then cat ${1} | while read line; do -- cgit v1.2.1