Gentoo Archives: gentoo-user

From: "J." <jyo.garcia@×××××.com>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Safe systemd "reload" command
Date: Sun, 05 Jun 2016 07:23:41
Message-Id: 1465111405.5349.53.camel@gmail.com
In Reply to: Re: [gentoo-user] Safe systemd "reload" command by Michael Orlitzky
1 El sáb, 04-06-2016 a las 21:01 -0400, Michael Orlitzky escribió:
2 > On 06/04/2016 08:47 PM, Michael Orlitzky wrote:
3 > >
4 > >
5 > > Sounds good, do you want to try it and add it to the wiki? =)
6 > >
7 > I just made an attempt and added it to the wiki:
8 >
9 >   https://wiki.gentoo.org/wiki/SpamAssassin#Daily_updates
10 >
11 > It doesn't have any affect on my openrc system (good), but I would
12 > still
13 > appreciate it if someone with systemd can tell me that it works.
14 >
15 >
16 I run systemd , but I have not tested your script, as of now I'm not
17 using spamassassin, but I will at some time in near future; but looking
18 at the script, I see some problems, you run the OpenRC restart commands
19 even if systemd is available, further it doesn't know which one is
20 running, as both can be installed(And are installed if using systemd),
21 so I would change it to be something like:
22
23 /etc/cron.daily/spamassassin-rule-updates:
24 #!/bin/bash
25 #
26 # Update SpamAssassin rules and reload daemons that use them.
27 #
28
29 # First, redirect stdout to /dev/null.
30 exec 1>/dev/null
31
32 # This thing sometimes spits out its progress onto stderr. If you
33 # don't have that problem (at least one user reports I'm crazy),
34 # then you'd be better off without the redirection here.
35 sa-update 2>/dev/null
36
37 # Exit code 0 means new updates were installed. Exit code 1 means 
38 # that we were already up-to-date. Anything else is failure.
39 if [ $? -eq 0 ]; then
40     sa-compile
41
42     # find out which init system is running, 
43     # the one running  as PID 1, will be set to 1
44     OPENRC_INIT_PID=`pgrep -o -U 0 init`
45     SYSTEMD_INIT_PID=`pgrep -o -U 0 systemd`
46
47
48     # Do you run spamd or amavisd? Both daemons need to be reloaded
49     # in order to pick up the newly-updated rules. These "status"
50     # checks should succeed only when the daemon is running. They are
51     # OpenRC-specific, but sys-apps/openrc is part if @system so that
52     # should be fine.
53     if command -v rc-service &>/dev/null &&\
54  [[ $OPENRC_INIT_PID -eq 1 ]] ; then 
55         rc-service spamd status && /etc/init.d/spamd reload
56         rc-service amavisd status && /etc/init.d/amavisd reload
57     fi
58
59     if command -v systemctl &>/dev/null &&\
60  [[ $SYSTEMD_INIT_PID -eq 1 ]] ; then
61         # The systemctl (systemd) executable is installed,
62 # so try to use it to restart spamd and amavisd.
63         systemctl try-restart spamassassin
64         systemctl try-restart amavisd
65     fi
66 fi

Replies

Subject Author
Re: [gentoo-user] Safe systemd "reload" command Michael Orlitzky <mjo@g.o>
Re: [gentoo-user] Safe systemd "reload" command Tom H <tomh0665@×××××.com>