diff mbox

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

Message ID 1408286648-19031-1-git-send-email-vapier@gentoo.org (mailing list archive)
State New, archived
Headers show

Commit Message

Mike Frysinger Aug. 17, 2014, 2:44 p.m. UTC
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

Comments

Steve Dickson Aug. 18, 2014, 5:04 p.m. UTC | #1
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
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mike Frysinger Aug. 18, 2014, 11:57 p.m. UTC | #2
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
Steve Dickson Aug. 19, 2014, 2:06 p.m. UTC | #3
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.

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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