spamassassin automated update

Discussion in 'Installation/Configuration' started by oxygen, Mar 10, 2016.

  1. oxygen

    oxygen Member

  2. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    To answer your questions, yes, that would work on ubuntu, and yes, amavisd-new would need reloaded after downloading rule updates.

    However, nowadays Debian ships with a cronjob (/etc/cron.daily/spamassassin) to run sa-update already, and a quick search indicates Ubuntu 14.04 has one, too. It may run sa-update right out of the box, or maybe you need a little config, I don't know offhand (don't have a Ubuntu server).
    oxygen likes this.
  3. Well-Known Member HowtoForge Supporter

    According to their mailing list, my guess is yes it does need a restart.

    Edit, ah missed by one minute =)
    oxygen likes this.
  4. oxygen

    oxygen Member

    I found spamassassin in cron.daily :)
    but nothing about amavisd.
    content of /etc/cron.daily/spamassassin:
    # Duncan Findlay
    # [email protected]
    # Daily cronjob for SpamAssassin updates. This isn't pretty but it
    # should do the job.
    test -f /etc/default/spamassassin && . /etc/default/spamassassin
    test -x /usr/bin/sa-update || exit 0
    test -x /etc/init.d/spamassassin || exit 0
    if [ "$CRON" = "0" ] ; then
        exit 0
    # If there's a problem with the ruleset or configs, print the output
    # of spamassassin --lint (which will typically get emailed to root)
    # and abort.
    die_with_lint() {
        su - debian-spamd -c "spamassassin --lint -D 2>&1"
        exit 1
    do_compile() {
    # Compile rules if the required tools are available. Prior to version
    # 3.3.2-8, there was an additional check to verify that an sa-compile
    # run had previously been executed by hand. With sa-learn now
    # distributed in a separate, optional, package, this check is no
    # longer necessary.
        if [ -x /usr/bin/re2c -a -x /usr/bin/sa-compile ]; then
            su - debian-spamd -c "sa-compile --quiet"
            # Fixup perms -- group and other should be able to
            # read and execute, but never write.  Works around
            # sa-compile's failure to obey umask.
            chmod -R go-w,go+rX /var/lib/spamassassin/compiled
    # Tell a running spamd to reload its configs and rules.
    reload() {
        # Reload
        if which invoke-rc.d >/dev/null 2>&1; then
        invoke-rc.d spamassassin reload > /dev/null
        /etc/init.d/spamassassin reload > /dev/null
        if [ -d /etc/spamassassin/sa-update-hooks.d ]; then
            run-parts --lsbsysinit /etc/spamassassin/sa-update-hooks.d
    # Sleep for up to 3600 seconds
    number=`od -vAn -N2 -tu4 < /dev/urandom`
    number=`expr $number "%" $RANGE`
    sleep $number
    # Update
    umask 022
    su - debian-spamd -c "sa-update --gpghomedir /var/lib/spamassassin/sa-update-keys"
    case $? in
            # got updates!
            su - debian-spamd -c "spamassassin --lint" || die_with_lint
            # no updates
            exit 0
            # lint failed!
            echo "sa-update failed for unknown reasons" 1>&2
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    It might be better to add an amavis restart or reload either as separate cronjob or in the spamassassin cronjob file.
  6. oxygen

    oxygen Member

    I found one more file, etc/cron.d/amavisd-new
    #  SpamAssassin maintenance for amavisd-new
    # m h dom mon dow user  command
    18 */3    * * *    amavis    test -e /usr/sbin/amavisd-new-cronjob && /usr/sbin/amavisd-new-cronjob sa-sync
    24 1  * * *   amavis  test -e /usr/sbin/amavisd-new-cronjob && /usr/sbin/amavisd-new-cronjob sa-clean 
  7. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    That amavisd cronjob is related to bayes database maintenance, not reloading after sa-update. Look in
    /etc/spamassassin/sa-update-hooks.d/ and you probably have an amavisd-new file which does reload amavisd, and is called from the spamassassin cronjob you pasted above.
    oxygen likes this.
  8. oxygen

    oxygen Member

    #This scripts restarts amavisd-new after spamassassin
    #rules got updated
    Thanks you are Chuck Norris in Linux! :D

Share This Page