diff mbox

[nfs-utils] start-statd: clean up output when systemd is not installed

Message ID 20140819110603.38b92ecb@notabene.brown (mailing list archive)
State New, archived
Headers show

Commit Message

NeilBrown Aug. 19, 2014, 1:06 a.m. UTC
On Mon, 18 Aug 2014 19:57:49 -0400 Mike Frysinger <vapier@gentoo.org> wrote:

> On Mon 18 Aug 2014 13:04:35 Steve Dickson wrote:
> > On 08/17/2014 10:44 AM, Mike Frysinger wrote:
> > > If you don't have systemd, then this script dumps:
> > > /usr/sbin/start-statd: line 8: systemctl: command not found
> > > 
> > > This isn't terribly useful since we ultimately fall back to running
> > > the daemon ourselves, so probe for systemd's existence before we try
> > > to use it.
> > > 
> > > Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> > 
> > Committed... but I used 'rpm -q systemd' instead of 'systemctl --help'
> > to test for the existences of systemd
> > 
> >  # First try systemd if it's installed.
> > -if systemctl --help >/dev/null 2>&1; then
> > +if rpm -q systemd > /dev/null 2>&1; then
> >      # Quit only if the call worked.
> >      systemctl start rpc-statd.service && exit
> 
> what about all the other distros not using rpm ?  my version was distro 
> agnostic.
> -mike

distro-agnotic is certainly important.
I would have gone with:



why call systemctl twice (once with --help and once with "start")?

NeilBrown

Comments

Mike Frysinger Aug. 19, 2014, 3:28 a.m. UTC | #1
On Tue 19 Aug 2014 11:06:03 NeilBrown wrote:
> On Mon, 18 Aug 2014 19:57:49 -0400 Mike Frysinger <vapier@gentoo.org> wrote:
> > On Mon 18 Aug 2014 13:04:35 Steve Dickson wrote:
> > > On 08/17/2014 10:44 AM, Mike Frysinger wrote:
> > > > If you don't have systemd, then this script dumps:
> > > > /usr/sbin/start-statd: line 8: systemctl: command not found
> > > > 
> > > > This isn't terribly useful since we ultimately fall back to running
> > > > the daemon ourselves, so probe for systemd's existence before we try
> > > > to use it.
> > > > 
> > > > Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> > > 
> > > Committed... but I used 'rpm -q systemd' instead of 'systemctl --help'
> > > to test for the existences of systemd
> > > 
> > >  # First try systemd if it's installed.
> > > 
> > > -if systemctl --help >/dev/null 2>&1; then
> > > +if rpm -q systemd > /dev/null 2>&1; then
> > > 
> > >      # Quit only if the call worked.
> > >      systemctl start rpc-statd.service && exit
> > 
> > what about all the other distros not using rpm ?  my version was distro
> > agnostic.
> > -mike
> 
> distro-agnotic is certainly important.
> I would have gone with:
> 
> diff --git a/utils/statd/start-statd b/utils/statd/start-statd
> index dcdaf7763f18..414f73f58096 100644
> --- a/utils/statd/start-statd
> +++ b/utils/statd/start-statd
> @@ -5,7 +5,7 @@
>  # It should run statd with whatever flags are apropriate for this
>  # site.
>  PATH="/sbin:/usr/sbin:/bin:/usr/bin"
> -if systemctl start rpc-statd.service
> +if systemctl start rpc-statd.service > /dev/null 2>&1
>  then :
>  else
>      exec rpc.statd --no-notify
> 
> 
> why call systemctl twice (once with --help and once with "start")?

because i don't think you want to silence errors from systemd when it's 
actually in use.  probing with --help tells you whether it exists.
-mike
diff mbox

Patch

diff --git a/utils/statd/start-statd b/utils/statd/start-statd
index dcdaf7763f18..414f73f58096 100644
--- a/utils/statd/start-statd
+++ b/utils/statd/start-statd
@@ -5,7 +5,7 @@ 
 # It should run statd with whatever flags are apropriate for this
 # site.
 PATH="/sbin:/usr/sbin:/bin:/usr/bin"
-if systemctl start rpc-statd.service
+if systemctl start rpc-statd.service > /dev/null 2>&1
 then :
 else
     exec rpc.statd --no-notify