Make the fcoe init script provide more useful information when used for
status.

Signed-off-by: Mark Rustad <mark.d.rus...@intel.com>
Tested-by: Ross Brattain <ross.b.bratt...@intel.com>
---
 etc/initd/initd.fedora |   24 ++++++++----------------
 etc/initd/initd.suse   |    4 ++++
 2 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/etc/initd/initd.fedora b/etc/initd/initd.fedora
index d1901ce..41ba193 100755
--- a/etc/initd/initd.fedora
+++ b/etc/initd/initd.fedora
@@ -32,6 +32,7 @@
 CONFIG_DIR=/etc/fcoe
 PID_FILE="/var/run/fcoemon.pid"
 LOG_FILE="/var/log/fcoemon.log"
+LOCKFILE="/var/lock/subsys/fcoe"
 FCOEMON=/usr/sbin/fcoemon
 FCOEADM=/usr/sbin/fcoeadm
 FCOEMON_OPTS=
@@ -73,7 +74,7 @@ start()
        daemon --pidfile ${PID_FILE} ${FCOEMON} ${FCOEMON_OPTS}
 
        echo
-       touch /var/lock/subsys/fcoe
+       touch ${LOCKFILE}
 
        echo
 }
@@ -95,19 +96,15 @@ stop()
        action $"Stopping FCoE initiator service: "
 
        rm -f ${PID_FILE}
-       rm -f /var/lock/subsys/fcoe
+       rm -f ${LOCKFILE}
 }
 
 status()
 {
+       [ -f ${LOCKFILE} ] || { echo "$FCOEMON is stopped" ; return 3; }
+
        status=0
-       pidof $FCOEMON
-       if [ $? -eq 0 ]; then
-               echo "$FCOEMON -- RUNNING, pid=`cat $PID_FILE`"
-       else
-               echo "$FCOEMON -- UNUSED"
-               status=3
-       fi
+       echo "$FCOEMON is running, pid=`cat $PID_FILE`"
 
        interfaces=`$FCOEADM -i 2>&1 | \
                    awk '/Symbolic Name:/{print $6}' | \
@@ -115,16 +112,11 @@ status()
 
        if [ -z "$interfaces" ]; then
                echo "No interfaces created."
+               status=2
        else
                echo "Created interfaces: $interfaces"
-               status=0
-       fi
-       if [ -f /var/lock/subsys/fcoe -a $status -eq 3 ]; then
-               status=2
-       fi
-       if [ -f ${PID_FILE} -a $status -eq 3 ]; then
-               status=1
        fi
+
        return $status
 }
 
diff --git a/etc/initd/initd.suse b/etc/initd/initd.suse
index 3ac9e7a..e3df550 100755
--- a/etc/initd/initd.suse
+++ b/etc/initd/initd.suse
@@ -121,6 +121,10 @@ status()
        echo -n "Checking status for fcoe service "
        checkproc -p ${PID_FILE} ${FCOEMON}
        rc_status -v
+       if [ $? -ne 0 ]; then
+               return;
+       fi
+
        interfaces=`$FCOEADM -i 2>&1 | \
                    awk '/Symbolic Name:/{print $6}' | \
                    sort | awk '{printf("%s ", $1)}'`

_______________________________________________
devel mailing list
devel@open-fcoe.org
https://lists.open-fcoe.org/mailman/listinfo/devel

Reply via email to