X-Git-Url: http://git.sven.stormbind.net/?p=sven%2Fmpt-status.git;a=blobdiff_plain;f=mpt-status.init;h=af69e06b2163d0eee5b797bcdede2c806542450d;hp=5209872c8f779c5b6fc2a795855a09accc7cf0ea;hb=92a17ae60f4fb696d6094e0038c9918582d537ff;hpb=25b013a48c5028333a17745a0ee27b60488308a6 diff --git a/mpt-status.init b/mpt-status.init index 5209872..af69e06 100644 --- a/mpt-status.init +++ b/mpt-status.init @@ -1,6 +1,7 @@ #! /bin/sh # Author: Petter Reinholdtsen +# Author: Sven Hoexter # License: GNU General Public License v2 or later # mpt-statusd - Check mpt-status values in the background. @@ -24,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 @@ -141,7 +142,9 @@ d_start() { 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" return 0 @@ -153,10 +156,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 + log_failure_msg "$NAME failed to stop" + return 1 + fi else - log_warning_msg "Daemon is already stopped." + log_warning_msg "$NAME is already stopped." return 0 fi } @@ -165,8 +176,8 @@ d_stop() { # therefore can be used by a restart d_stop_by_restart() { if [ -f $PIDFILE ] ; then - killproc -p $PIDFILE $SCRIPTNAME > /dev/null 2>&1 - rm -f $PIDFILE + killproc -p $PIDFILE $SCRIPTNAME > /dev/null 2>&1 + rm -f $PIDFILE $LOCKFILE else log_warning_msg "Daemon is already stopped." fi @@ -174,22 +185,24 @@ d_stop_by_restart() { case "$1" in start) - echo -n "" - 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