]> git.sven.stormbind.net Git - sven/mpt-status.git/blobdiff - mpt-status.init
Remove dependency on redhat-lsb.
[sven/mpt-status.git] / mpt-status.init
index 7e72bb0b5acc17aeb380253923c60a9a5454413d..b5fa7caf5984c0b11c793fdcec6aed3d2b40f199 100644 (file)
@@ -25,7 +25,7 @@ NAME=mpt-statusd
 PIDFILE=/var/run/$NAME.pid
 STATUSFILE=/var/run/$NAME.status
 SCRIPTNAME=/etc/init.d/$NAME
-
+LOCKFILE=/var/lock/subsys/$NAME
 
 # Do not touch you can configure this in /etc/default/mpt-statusd
 MAILTO=root   # Where to report problems
@@ -41,10 +41,9 @@ test -x /usr/sbin/mpt-status || exit 0
 
 # Source function library.
 . /etc/rc.d/init.d/functions
-. /lib/lsb/init-functions
 
 if [ $RUN_DAEMON = "no" ] ; then
-       log_failure_msg $"mpt-statusd is disabled in /etc/default/mpt-statusd, not starting."
+        echo "mpt-statusd is disabled in /etc/default/mpt-statusd, not starting." && failure
        exit 0
 fi
 
@@ -53,7 +52,7 @@ fi
 modprobe mptctl || true
 
 if ! [ -e "/proc/mpt/version" ] ; then
-       log_failure_msg "The mptctl module is missing."
+       echo "The mptctl module is missing." && failure
        exit 0
 fi
 
@@ -137,14 +136,16 @@ check_daemon() {
 d_start() {
     [ -f $PIDFILE ] && PID="`cat $PIDFILE`"
     if [ "$PID" ] ; then
-        log_warning_msg "Daemon already running. Refusing to start another"
+        echo "Daemon already running. Refusing to start another" && warning
         return 0
     elif check_daemon ; then
        # Use daemonize to turn it into a daemon and start it with daemon().
         daemon --pidfile $PIDFILE /usr/sbin/daemonize $SCRIPTNAME check_mpt
-       return 0
+       RETVAL=$?
+       [ $RETVAL -eq 0 ] && touch $LOCKFILE
+       return $RETVAL
     else
-        log_warning_msg "Daemon is already running. Refusing to start another"
+        echo "Daemon is already running. Refusing to start another" && warning
         return 0
     fi
 }
@@ -154,10 +155,18 @@ d_start() {
 #
 d_stop() {
         if [ -f $PIDFILE ] ; then
-               killproc -p $PIDFILE $SCRIPTNAME > /dev/null 2>&1 
-               rm -f $PIDFILE
+               killproc $SCRIPTNAME
+               RETVAL=$?
+               if [ $RETVAL -eq 0 ] ; then
+                   success "$NAME stopped"
+                   rm -f $PIDFILE $LOCKFILE
+                   return 0
+               else
+                   echo "$NAME failed to stop" && failure
+                   return 1
+               fi
         else
-                log_warning_msg "Daemon is already stopped."
+                echo "$NAME is already stopped." && warning
                 return 0
         fi
 }
@@ -167,29 +176,32 @@ d_stop() {
 d_stop_by_restart() {
         if [ -f $PIDFILE ] ; then
                 killproc -p $PIDFILE $SCRIPTNAME > /dev/null 2>&1
-                rm -f $PIDFILE
+                rm -f $PIDFILE $LOCKFILE
         else
-                log_warning_msg "Daemon is already stopped."
+                echo "Daemon is already stopped." && warning
         fi
 }
 
 case "$1" in
   start)
-        echo -n $"Starting $DESC: $NAME"
+        echo $"Starting $DESC: $NAME"
         d_start
+       echo
         ;;
   stop)
-        echo -n $"Stopping $DESC: $NAME"
+        echo $"Stopping $DESC: $NAME"
         d_stop
+       echo
         ;;
   check_mpt)
         check_mpt
         ;;
   restart|force-reload)
-        echo -n "Restarting $DESC: $NAME"
+        echo "Restarting $DESC: $NAME"
         d_stop_by_restart
         sleep 1
         d_start
+       echo
         ;;
   *)
         echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2