X-Git-Url: http://git.sven.stormbind.net/?a=blobdiff_plain;f=mpt-status.init;h=c30c4ac08623c9dd9e43c2bac5434616e47f9452;hb=5f91f5654b9b29cc4a18e031380e1eff903ea68f;hp=65b2e79bdccc9986b43e77b5aebf86a53adc36da;hpb=b417e89bc0b10bef788620ed0a86d9edd896da39;p=sven%2Fmpt-status.git diff --git a/mpt-status.init b/mpt-status.init index 65b2e79..c30c4ac 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. @@ -47,10 +48,14 @@ if [ $RUN_DAEMON = "no" ] ; then exit 0 fi -#if ! [ -e "/proc/mpt/version" ] ; then -# log_failure_msg "The mptctl module is missing." -# exit 0 -#fi + +#Try to blindly load the mptctl module +modprobe mptctl || true + +if ! [ -e "/proc/mpt/version" ] ; then + log_failure_msg "The mptctl module is missing." + exit 0 +fi check_mpt() { echo $$ > $PIDFILE.new && mv $PIDFILE.new $PIDFILE @@ -137,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 ] && rm -f $PIDFILE + return $RETVAL else log_warning_msg "Daemon is already running. Refusing to start another" return 0 @@ -149,8 +156,10 @@ d_start() { # d_stop() { if [ -f $PIDFILE ] ; then - killproc -p $PIDFILE $SCRIPTNAME > /dev/null 2>&1 - rm -f $PIDFILE + killproc $SCRIPTNAME + RETVAL=$? + [ $RETVAL -eq 0 ] && rm -f $PIDFILE + return $RETVAL else log_warning_msg "Daemon is already stopped." return 0 @@ -161,7 +170,7 @@ 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 + killproc -p $PIDFILE $SCRIPTNAME > /dev/null 2>&1 rm -f $PIDFILE else log_warning_msg "Daemon is already stopped." @@ -170,22 +179,24 @@ d_stop_by_restart() { case "$1" in start) - echo -n "" - echo -n $"Starting $DESC: $NAME" + echo $"Starting $DESC: $NAME" d_start + echo ;; stop) - log_begin_msg "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