public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: "J. García" <jyo.garcia@gmail.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] Safe systemd "reload" command
Date: Sun, 05 Jun 2016 01:23:25 -0600	[thread overview]
Message-ID: <1465111405.5349.53.camel@gmail.com> (raw)
In-Reply-To: <575379E4.9060506@gentoo.org>

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


  reply	other threads:[~2016-06-05  7:23 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-04 22:48 [gentoo-user] Safe systemd "reload" command Michael Orlitzky
2016-06-05  0:19 ` Rich Freeman
2016-06-05  0:47   ` Michael Orlitzky
2016-06-05  1:01     ` Michael Orlitzky
2016-06-05  7:23       ` J. García [this message]
2016-06-05 13:37         ` Michael Orlitzky
2016-06-05 14:31           ` Rich Freeman
2016-06-05 15:37           ` J. García
2016-06-05 15:44             ` J. García
2016-06-05 16:09             ` Michael Orlitzky
2016-06-05 16:27               ` J. García
2016-06-05 16:54                 ` Michael Orlitzky
2016-06-07  9:23                 ` Tom H
2016-06-06 22:17         ` Tom H
2016-06-06 22:04 ` Tom H
2016-06-06 22:59   ` Michael Orlitzky
2016-06-07 10:17     ` Tom H
2016-06-07 13:13       ` Michael Orlitzky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1465111405.5349.53.camel@gmail.com \
    --to=jyo.garcia@gmail.com \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox