El sáb, 04-06-2016 a las 21:01 -0400, Michael Orlitzky escribió:
> On 06/04/2016 08:47 PM, Michael Orlitzky wrote:
> >
> >
> > Sounds good, do you want to try it and add it to the wiki? =)
> >
> I just made an attempt and added it to the wiki:
>
> https://wiki.gentoo.org/wiki/SpamAssassin#Daily_updates
>
> It doesn't have any affect on my openrc system (good), but I would
> still
> appreciate it if someone with systemd can tell me that it works.
>
>
I run systemd , but I have not tested your script, as of now I'm not
using spamassassin, but I will at some time in near future; but looking
at the script, I see some problems, you run the OpenRC restart commands
even if systemd is available, further it doesn't know which one is
running, as both can be installed(And are installed if using systemd),
so I would change it to be something like:
/etc/cron.daily/spamassassin-rule-updates:
#!/bin/bash
#
# Update SpamAssassin rules and reload daemons that use them.
#
# First, redirect stdout to /dev/null.
exec 1>/dev/null
# This thing sometimes spits out its progress onto stderr. If you
# don't have that problem (at least one user reports I'm crazy),
# then you'd be better off without the redirection here.
sa-update 2>/dev/null
# Exit code 0 means new updates were installed. Exit code 1 means
# that we were already up-to-date. Anything else is failure.
if [ $? -eq 0 ]; then
sa-compile
# find out which init system is running,
# the one running as PID 1, will be set to 1
OPENRC_INIT_PID=`pgrep -o -U 0 init`
SYSTEMD_INIT_PID=`pgrep -o -U 0 systemd`
# Do you run spamd or amavisd? Both daemons need to be reloaded
# in order to pick up the newly-updated rules. These "status"
# checks should succeed only when the daemon is running. They are
# OpenRC-specific, but sys-apps/openrc is part if @system so that
# should be fine.
if command -v rc-service &>/dev/null &&\
[[ $OPENRC_INIT_PID -eq 1 ]] ; then
rc-service spamd status && /etc/init.d/spamd reload
rc-service amavisd status && /etc/init.d/amavisd reload
fi
if command -v systemctl &>/dev/null &&\
[[ $SYSTEMD_INIT_PID -eq 1 ]] ; then
# The systemctl (systemd) executable is installed,
# so try to use it to restart spamd and amavisd.
systemctl try-restart spamassassin
systemctl try-restart amavisd
fi
fi