#!/bin/sh

/usr/bin/sa-update
ERR=$?

# Only restart spamd if sa-update returns 0, meaning it updated the rules
if [ $ERR -eq 0 ]; then
	/etc/init.d/psa-spamassassin restart | tee -a /var/log/sa-update.log;
fi

# if sa-update returns 1 when there are no updates
if [ $ERR -eq 1 ]; then
	exit 0;
fi

exit $ERR

