]> git.openfabrics.org - ~ardavis/dapl.git/commitdiff
Orchestrate the handling of pid and lock files
authorJianxin Xiong <jianxin.xiong@intel.com>
Wed, 26 Sep 2012 21:03:58 +0000 (14:03 -0700)
committerJianxin Xiong <jianxin.xiong@intel.com>
Wed, 26 Sep 2012 21:03:58 +0000 (14:03 -0700)
From: pmmccorm <patrick.m.mccormick@intel.com>

mpxyd.init.in

index 3c68f1e992ab97f990b130f86827c21b574436e9..2abba8a1356d53ea6096ae4f7d4c1ddf2187781a 100644 (file)
 #      that enables MIC clients to proxy InfiniBand RDMA over to large core resources
 ### END INIT INFO
 
-pidfile=/var/run/mpxyd.pid
-subsys=/var/lock/subsys/mpxyd
+prog=mpxyd
+execpath=@prefix@/sbin/${prog}
+pidfile=/var/run/${prog}.pid
+subsys=/var/lock/subsys/${prog}
 
 . /etc/rc.d/init.d/functions
 
@@ -27,9 +29,11 @@ start()
 {
     echo -n "Starting mpxyd daemon:"
 
-    daemon @prefix@/sbin/mpxyd
+    daemon --check $prog --pidfile "${pidfile}" $execpath
     RC=$?
-    [ $RC -eq 0 ] && touch $subsys
+
+    [ "$RC" -eq "0" ] && touch $subsys
+
     echo
     return $RC
 }
@@ -38,25 +42,16 @@ stop()
 {
     echo -n "Stopping mpxyd daemon:"
 
-    killproc -p $pidfile mpxyd
+    killproc -p $pidfile $execpath
     RC=$?
     rm -f $subsys
     echo
     return $RC
 }
 
-status()
+_status()
 {
-    if [ ! -f $subsys -a ! -f $pidfile ]; then
-       return 3
-    fi
-    if [ -f $pidfile ]; then
-       checkpid `cat $pidfile`
-       return $?
-    fi
-    if [ -f $subsys ]; then
-       return 2
-    fi
+    status -p "${pidfile}" -l "${subsys}" ${prog}
 }
 
 restart ()
@@ -91,7 +86,7 @@ case $1 in
     condrestart) condrestart; RC=$? ;;
     try-restart) condrestart; RC=$? ;;
     force-reload) condrestart; RC=$? ;;
-    status) status; RC=$? ;;
+    status) _status; RC=$? ;;
     *) usage; RC=$? ;;
 esac