linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nfs-utils] start-statd: clean up output when systemd is not installed
@ 2014-08-17 14:44 Mike Frysinger
  2014-08-18 17:04 ` Steve Dickson
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Frysinger @ 2014-08-17 14:44 UTC (permalink / raw)
  To: linux-nfs

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>
---
 utils/statd/start-statd | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
 mode change 100644 => 100755 utils/statd/start-statd

diff --git a/utils/statd/start-statd b/utils/statd/start-statd
old mode 100644
new mode 100755
index dcdaf77..ec9383b
--- a/utils/statd/start-statd
+++ b/utils/statd/start-statd
@@ -1,12 +1,16 @@
-#!/bin/bash -p
+#!/bin/sh
 # nfsmount calls this script when mounting a filesystem with locking
 # enabled, but when statd does not seem to be running (based on
 # /var/run/rpc.statd.pid).
 # 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
-then :
-else
-    exec rpc.statd --no-notify
+
+# First try systemd if it's installed.
+if systemctl --help >/dev/null 2>&1; then
+    # Quit only if the call worked.
+    systemctl start rpc-statd.service && exit
 fi
+
+# Fall back to launching it ourselves.
+exec rpc.statd --no-notify
-- 
2.0.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH nfs-utils] start-statd: clean up output when systemd is not installed
  2014-08-17 14:44 [PATCH nfs-utils] start-statd: clean up output when systemd is not installed Mike Frysinger
@ 2014-08-18 17:04 ` Steve Dickson
  2014-08-18 23:57   ` Mike Frysinger
  0 siblings, 1 reply; 6+ messages in thread
From: Steve Dickson @ 2014-08-18 17:04 UTC (permalink / raw)
  To: Mike Frysinger, linux-nfs



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


steved.

> ---
>  utils/statd/start-statd | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
>  mode change 100644 => 100755 utils/statd/start-statd
> 
> diff --git a/utils/statd/start-statd b/utils/statd/start-statd
> old mode 100644
> new mode 100755
> index dcdaf77..ec9383b
> --- a/utils/statd/start-statd
> +++ b/utils/statd/start-statd
> @@ -1,12 +1,16 @@
> -#!/bin/bash -p
> +#!/bin/sh
>  # nfsmount calls this script when mounting a filesystem with locking
>  # enabled, but when statd does not seem to be running (based on
>  # /var/run/rpc.statd.pid).
>  # 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
> -then :
> -else
> -    exec rpc.statd --no-notify
> +
> +# First try systemd if it's installed.
> +if systemctl --help >/dev/null 2>&1; then
> +    # Quit only if the call worked.
> +    systemctl start rpc-statd.service && exit
>  fi
> +
> +# Fall back to launching it ourselves.
> +exec rpc.statd --no-notify
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH nfs-utils] start-statd: clean up output when systemd is not installed
  2014-08-18 17:04 ` Steve Dickson
@ 2014-08-18 23:57   ` Mike Frysinger
  2014-08-19  1:06     ` NeilBrown
  2014-08-19 14:06     ` Steve Dickson
  0 siblings, 2 replies; 6+ messages in thread
From: Mike Frysinger @ 2014-08-18 23:57 UTC (permalink / raw)
  To: Steve Dickson; +Cc: linux-nfs

[-- Attachment #1: Type: text/plain, Size: 889 bytes --]

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

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH nfs-utils] start-statd: clean up output when systemd is not installed
  2014-08-18 23:57   ` Mike Frysinger
@ 2014-08-19  1:06     ` NeilBrown
  2014-08-19  3:28       ` Mike Frysinger
  2014-08-19 14:06     ` Steve Dickson
  1 sibling, 1 reply; 6+ messages in thread
From: NeilBrown @ 2014-08-19  1:06 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: Steve Dickson, linux-nfs

[-- Attachment #1: Type: text/plain, Size: 1616 bytes --]

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")?

NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH nfs-utils] start-statd: clean up output when systemd is not installed
  2014-08-19  1:06     ` NeilBrown
@ 2014-08-19  3:28       ` Mike Frysinger
  0 siblings, 0 replies; 6+ messages in thread
From: Mike Frysinger @ 2014-08-19  3:28 UTC (permalink / raw)
  To: NeilBrown; +Cc: Steve Dickson, linux-nfs

[-- Attachment #1: Type: text/plain, Size: 1899 bytes --]

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

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH nfs-utils] start-statd: clean up output when systemd is not installed
  2014-08-18 23:57   ` Mike Frysinger
  2014-08-19  1:06     ` NeilBrown
@ 2014-08-19 14:06     ` Steve Dickson
  1 sibling, 0 replies; 6+ messages in thread
From: Steve Dickson @ 2014-08-19 14:06 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: linux-nfs



On 08/18/2014 07:57 PM, Mike Frysinger 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.
Good point... I just committed your original version... Thanks!

steved.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-08-19 14:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-17 14:44 [PATCH nfs-utils] start-statd: clean up output when systemd is not installed Mike Frysinger
2014-08-18 17:04 ` Steve Dickson
2014-08-18 23:57   ` Mike Frysinger
2014-08-19  1:06     ` NeilBrown
2014-08-19  3:28       ` Mike Frysinger
2014-08-19 14:06     ` Steve Dickson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).