#!/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/admispconfig/ispconfig/tools/spamassassin/usr/bin
#########################################################################################################################
#Written by Jason Shewchuk #
#E-Mail: jason <> shewchuk.ca #
#Version: 0 #
#Date Created: Sept. 20, 2006 #
#Date Modified: Sept. 20, 2006 #
#Feel free to use and modify this script. Let me know of changes you have made so I can learn and improve this script #
#########################################################################################################################
#Today's date
today=$(date +%Y_%m_%d)
#Run sa-update
/home/admispconfig/ispconfig/tools/spamassassin/usr/bin/sa-update
exitcode=$? #Exit code from sa-update
#Find version of sa-update
version=$(/home/admispconfig/ispconfig/tools/spamassassin/usr/bin/sa-update -V | grep "sa-update")
if [ $exitcode = 0 ]; then
echo "An update was available, and was downloaded and installed successfully. You are now running $version." | formail -c -I"Subject: sa-update Updated for $today - Updated" -I"From: sa-update@localhost" -I"To: admin@host.com" -I"Received: from Server" | sendmail admin@host.com
elif [ $exitcode = 1 ]; then
echo "No update was available. You are still running $version."
else
echo "An error occured while attempting to download and extract updates. You are still running $version." | formail -c -I"Subject: sa-update Update Status for $today - Error" -I"From: sa-updater@localhost" -I"To: admin@host.com" -I"Received: from Server" | sendmail admin@host.com
fi
exit 0