[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: migration from cron.daily to systemd timers



On 1/8/20 4:25 PM, Josh Triplett wrote:
> (I would suggest doing the same for the cron job, for new installations:
> put the script itself in /usr/lib/spamassassin or similar, and document
> that people can enable it by either enabling the systemd timer, linking
> the script from cron.daily, or copying the script to cron.daily if they
> really want to modify it.)

It seems like this would work well. That's better than my previous
proposal and the current commit, as it doesn't result in a cron.daily
script starting just to exit.

It looks like the existing commit uses /usr/sbin/spamassassin-maint, so
I'll use that instead for the example. I personally wouldn't put this
script in the PATH, but that's a separate issue.

The migration would then look something like this:

[ -e /etc/default/spamassassin ] && . /etc/default/spamassassin
if ! [ -L /etc/cron.daily/spamassassin ] &&
   ! TODO_check_for_local_changes ; then
    if [ "$CRON" = "1" ] ; then
        if [ -d /run/systemd/system ]; then
            systemctl enable spamassassin-daily-maintenance.timer
            rm -f /etc/cron.daily/spamassassin
        else
            ln -sf /usr/sbin/spamassassin-maint \
                /etc/cron.daily/spamassassin
        fi
    else
        rm -f /etc/cron.daily/spamassassin
    fi
fi

So, if the user changed it, just leave everything alone. If they didn't
change it and aren't using it, remove it. If they didn't change it but
are using it, replace it with a symlink or a systemd unit, depending on
whether systemd is in use.

This covers everything except the case of: they're using it, but did not
modify it, and are using systemd, but don't want systemd timers. In that
case, the user would have to disable the systemd timer and add the
symlink. I'd mention this in the NEWS.

With this proposeal, the maintenance script should also stop checking
CRON= (or for the systemd timer), and CRON= should be removed from
/etc/default/spamassassin (though that needs to be done AFTER the check
above fires).

-- 
Richard

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: