]> git.pld-linux.org Git - projects/rc-scripts.git/commitdiff
- status() improved so it can accept now two argumens: the subsys
authorJacek Konieczny <jajcus@pld-linux.org>
Thu, 14 Dec 2000 09:49:25 +0000 (09:49 +0000)
committerJacek Konieczny <jajcus@pld-linux.org>
Thu, 14 Dec 2000 09:49:25 +0000 (09:49 +0000)
  name and (optional) the daemon name. status() checks if daemon is running
  or the subsys is locked. This way subsys name can differ from daemon name it
  is running

svn-id: @847

rc.d/init.d/functions

index e5b13d92b3b2f8f7b1c743d6c2aaafda987b8d50..b230f58ef902140a9a5371b3217d8ea77da377b6 100644 (file)
@@ -1,7 +1,7 @@
 # functions    This file contains functions to be used by most or all
 #              shell scripts in the /etc/init.d directory.
 #
-# $Id: functions,v 1.61 2000/12/09 12:02:47 mkochano Exp $
+# $Id: functions,v 1.62 2000/12/14 09:49:25 jajcus Exp $
 #
 # Author:      Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
 # Hacked by:    Greg Galloway and Marc Ewing
@@ -390,14 +390,17 @@ status()
 {
        # Test syntax.
        if [ $# = 0 ] ; then
-               msg_usage " status {program}"
+               msg_usage " status {subsys} [{daemon}]"
                return 1
        fi
 
+       subsys=$1
+       daemon=${2:-$subsys}
+
        # First try "pidof"
-       pid=$(pidof -o $$ -o $PPID -o %PPID -x $1)
+       pid=$(pidof -o $$ -o $PPID -o %PPID -x $daemon)
        if [ -n "$pid" ] ; then
-               nls "%s (pid %s) is running..." "$1" "$pid"
+               nls "%s (pid %s) is running..." "$daemon" "$pid"
                return 0
         else
                 pid=`ps ax | awk 'BEGIN { prog=ARGV[1]; ARGC=1 }
@@ -405,25 +408,25 @@ status()
                              (("[" prog "]") == $5) ||
                            ((prog ":") == $5)) { print $1 ; exit 0 } }' $1`
                 if [ "$pid" != "" ] ; then
-                        nls "%s (pid %s) is running..." "$1" "$pid"
+                        nls "%s (pid %s) is running..." "$daemon" "$pid"
                         return 0
                 fi
        fi
 
        # Next try "/var/run/*.pid" files
-       if [ -f /var/run/$1.pid ] ; then
+       if [ -f /var/run/$daemon.pid ] ; then
                pid=$(head -1 /var/run/$1.pid)
                if [ -n "$pid" ] ; then
                        nls "%s dead but pid file exists" "$1"
                        return 1
                fi
        fi
-       # See if /var/lock/subsys/$1 exists
-       if [ -f /var/lock/subsys/$1 ]; then
-               nls "%s dead but subsys locked" "$1"
+       # See if /var/lock/subsys/$subsys exists
+       if [ -f /var/lock/subsys/$subsys ]; then
+               nls "%s dead but subsys locked" "$daemon"
                return 2
        fi
-       nls "%s is stopped" "$1"
+       nls "%s is stopped" "$subsys"
        return 3
 }
 
This page took 0.056267 seconds and 4 git commands to generate.