#!/bin/bash
### Copyright 1999-2025. WebPros International GmbH. All rights reserved.

sa_update()
{
	/usr/bin/sa-update -D
	local rc="$?"
	case $rc in
		# Only restart spamd if sa-update returns 0, meaning it updated the rules
		0) env PATH=/opt/psa/admin/sbin:/usr/local/psa/admin/sbin:$PATH spammng --condrestart ;;
		# If sa-update returns 1 then there are no updates
		1) exit 0 ;;
	esac
	return $rc
}

sa_update >> /var/log/sa-update.log 2>&1

