Commit 646d49d1 authored by Vladimir Bashkirtsev's avatar Vladimir Bashkirtsev

Configured systemd unit file and periodic update

parent 2b23350a
all: all: spamassassin-service sa-update-service sa-update-timer
tar xf Mail-SpamAssassin-3.4.4.tar.bz2 tar xf Mail-SpamAssassin-3.4.4.tar.bz2
cd Mail-SpamAssassin-3.4.4 && perl Makefile.PL cd Mail-SpamAssassin-3.4.4 && perl Makefile.PL
$(MAKE) -C Mail-SpamAssassin-3.4.4 $(MAKE) -C Mail-SpamAssassin-3.4.4
$(MAKE) -C Mail-SpamAssassin-3.4.4 install $(MAKE) -C Mail-SpamAssassin-3.4.4 install
install -v -Dm755 sa-update.cron /usr/share/spamassassin
@echo "$$SPAMASSASSIN_SERVICE" > /lib/systemd/system/spamassassin.service
systemctl enable spamassassin.service
@echo "$$SA_UPDATE_SERVICE" > /lib/systemd/system/sa-update.service
@echo "$$SA_UPDATE_TIMER" > /lib/systemd/system/sa-update.timer
install -d -m700 /etc/mail/spamassassin/sa-update-keys
rm -rf Mail-SpamAssassin-3.4.4 rm -rf Mail-SpamAssassin-3.4.4
spamassassin-service:
define SPAMASSASSIN_SERVICE
[Unit]
Description=Spamassassin daemon
After=syslog.target network.target
Wants=sa-update.timer
[Service]
ExecStart=/usr/bin/spamd
Restart=always
[Install]
WantedBy=multi-user.target
endef
export SPAMASSASSIN_SERVICE
sa-update-service:
define SA_UPDATE_SERVICE
### Spamassassin Rules Updates ###
#
# http://wiki.apache.org/spamassassin/RuleUpdates
#
# sa-update automatically updates your rules once per day if a spam daemon like
# spamd or amavisd are running.
[Unit]
Description=Spamassassin Rules Update
Documentation=man:sa-update(1)
[Service]
# Note that the opposite of "yes" is the empty string, NOT "no"
# Options for the actual sa-update command
# These are added to the channel configuration from
# /etc/mail/spamassassin/channel.d/*.conf
Environment=OPTIONS=-v
# Debug script - send mail even if no update available
#Environment=DEBUG=yes
# Send mail when updates successfully processed
# Default: send mail only on error
#Environment=NOTIFY_UPD=yes
ExecStart=/usr/share/spamassassin/sa-update.cron
SuccessExitStatus=1
endef
export SA_UPDATE_SERVICE
sa-update-timer:
define SA_UPDATE_TIMER
### Spamassassin Rules Updates ###
#
# http://wiki.apache.org/spamassassin/RuleUpdates
#
# sa-update automatically updates your rules once per day if a spam daemon like
# spamd or amavisd are running.
[Unit]
Description=Spamassassin Rules Update timer
Documentation=man:sa-update(1)
[Timer]
OnCalendar=daily
[Install]
WantedBy=spamassassin.service
endef
export SA_UPDATE_TIMER
#!/bin/bash
# sa-update must create keyring
if [ ! -d /etc/mail/spamassassin/sa-update-keys ]; then
sa-update
fi
/usr/bin/sa-update
status=$?
now=`date +"%d-%b-%Y %T"`
if [ $status -eq 0 ]; then
echo "$now: SpamAssassin: Update processed successfully"
systemctl condrestart spamassassin.service >& /dev/null
systemctl --quiet is-active mimedefang.service; [ $? -eq 0 ] && systemctl reload mimedefang.service >& /dev/null
exit $status
fi
if [ $status -eq 1 ]; then
echo "$now: SpamAssassin: No update available"
exit $status
fi
if [ $status -eq 2 ]; then
echo "$now: SpamAssassin: Problem applying update - pre files failed lint check"
exit $status
fi
if [ $status -eq 4 ]; then
echo "$now: SpamAssassin: Update available, but download or extract failed"
exit $status
fi
echo "$now: SpamAssassin: Unknown error code $status from sa-update"
exit $status
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment