Patchwork [3/6] nfs-utils: add init.d/nfsserver status command for LSB compliance

login
register
mail settings
Submitter jackie huang
Date Aug. 20, 2013, 3:25 a.m.
Message ID <13b92f067594e8aceac11c7964242fafdfb21f8d.1376968627.git.jackie.huang@windriver.com>
Download mbox | patch
Permalink /patch/56021/
State New
Headers show

Comments

jackie huang - Aug. 20, 2013, 3:25 a.m.
From: Jackie Huang <jackie.huang@windriver.com>

Signed-off-by: Li Wang <li.wang@windriver.com>
Signed-off-by: Jackie Huang <jackie.huang@windriver.com>
---
 .../nfs-utils/nfs-utils/nfsserver                  |   25 ++++++++++++++++++-
 1 files changed, 23 insertions(+), 2 deletions(-)
Phil Blundell - Aug. 20, 2013, 6:36 a.m.
On Tue, 2013-08-20 at 11:25 +0800, jackie.huang@windriver.com wrote:
> @@ -23,6 +25,7 @@ test -r /etc/default/nfsd && . /etc/default/nfsd
>  test -x "$NFS_MOUNTD" || NFS_MOUNTD=/usr/sbin/rpc.mountd
>  test -x "$NFS_NFSD" || NFS_NFSD=/usr/sbin/rpc.nfsd
>  test -x "$NFS_STATD" || NFS_STATD=/usr/sbin/rpc.statd
> +test -z "$STATD_PID" && STATD_PID=/var/run/rpc.statd.pid
>  #
>  # The user mode program must also exist (it just starts the kernel
>  # threads using the kernel module code).
> @@ -75,6 +78,17 @@ stop_mountd(){
>  #
>  #nfsd
>  start_nfsd(){
> +        modprobe -q nfsd
> +	grep -q nfsd /proc/filesystems || {
> +		echo NFS daemon support not enabled in kernel
> +		exit 1
> +        }
> +	grep -q nfsd /proc/mounts || mount -t nfsd nfsd /proc/fs/nfsd
> +	grep -q nfsd /proc/mounts || {
> +		echo nfsd filesystem could not be mounted at /proc/fs/nfsd
> +		exit 1
> +        }
> +
>  	echo -n "starting $1 nfsd kernel threads: "
>  	start-stop-daemon --start --exec "$NFS_NFSD" -- "$@"
>  	echo done
> @@ -113,14 +127,14 @@ stop_nfsd(){
>  #statd
>  start_statd(){
>  	echo -n "starting statd: "
> -	start-stop-daemon --start --exec "$NFS_STATD"
> +	start-stop-daemon --start --exec "$NFS_STATD" --pidfile "$STATD_PID"
>  	echo done
>  }
>  stop_statd(){
>  	# WARNING: this kills any process with the executable
>  	# name 'statd'.
>  	echo -n 'stopping statd: '
> -	start-stop-daemon --stop --quiet --signal 1 --name statd
> +	start-stop-daemon --stop --quiet --signal 1 --pidfile "$STATD_PID"
>  	echo done
>  }
>  #----------------------------------------------------------------------

This stuff doesn't seem to e directly related to the "status" command.

p.

Patch

diff --git a/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver b/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver
index e460e26..494af2e 100644
--- a/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver
+++ b/meta/recipes-connectivity/nfs-utils/nfs-utils/nfsserver
@@ -14,6 +14,8 @@ 
 #
 # Startup script for nfs-utils
 #
+# Source function library.
+. /etc/init.d/functions
 #
 # The environment variable NFS_SERVERS may be set in /etc/default/nfsd
 # Other control variables may be overridden here too
@@ -23,6 +25,7 @@  test -r /etc/default/nfsd && . /etc/default/nfsd
 test -x "$NFS_MOUNTD" || NFS_MOUNTD=/usr/sbin/rpc.mountd
 test -x "$NFS_NFSD" || NFS_NFSD=/usr/sbin/rpc.nfsd
 test -x "$NFS_STATD" || NFS_STATD=/usr/sbin/rpc.statd
+test -z "$STATD_PID" && STATD_PID=/var/run/rpc.statd.pid
 #
 # The user mode program must also exist (it just starts the kernel
 # threads using the kernel module code).
@@ -75,6 +78,17 @@  stop_mountd(){
 #
 #nfsd
 start_nfsd(){
+        modprobe -q nfsd
+	grep -q nfsd /proc/filesystems || {
+		echo NFS daemon support not enabled in kernel
+		exit 1
+        }
+	grep -q nfsd /proc/mounts || mount -t nfsd nfsd /proc/fs/nfsd
+	grep -q nfsd /proc/mounts || {
+		echo nfsd filesystem could not be mounted at /proc/fs/nfsd
+		exit 1
+        }
+
 	echo -n "starting $1 nfsd kernel threads: "
 	start-stop-daemon --start --exec "$NFS_NFSD" -- "$@"
 	echo done
@@ -113,14 +127,14 @@  stop_nfsd(){
 #statd
 start_statd(){
 	echo -n "starting statd: "
-	start-stop-daemon --start --exec "$NFS_STATD"
+	start-stop-daemon --start --exec "$NFS_STATD" --pidfile "$STATD_PID"
 	echo done
 }
 stop_statd(){
 	# WARNING: this kills any process with the executable
 	# name 'statd'.
 	echo -n 'stopping statd: '
-	start-stop-daemon --stop --quiet --signal 1 --name statd
+	start-stop-daemon --stop --quiet --signal 1 --pidfile "$STATD_PID"
 	echo done
 }
 #----------------------------------------------------------------------
@@ -141,6 +155,13 @@  stop)	exportfs -ua
 	stop_statd
 	stop_mountd
 	stop_nfsd;;
+status)
+	status /usr/sbin/rpc.mountd;
+	RETVAL=$?
+	status nfsd;
+	rval=$?
+	[ $RETVAL -eq 0 ] && exit $rval
+	exit $RETVAL;;
 reload)	test -r /etc/exports && exportfs -r;;
 restart)exportfs -ua
 	stop_mountd