From: Sven Hoexter Date: Sun, 16 Oct 2011 13:57:16 +0000 (+0200) Subject: Port some of the obvious non-rhel compatible commands and functions. X-Git-Tag: 1.2.0-3~7 X-Git-Url: https://git.sven.stormbind.net/?a=commitdiff_plain;h=b417e89bc0b10bef788620ed0a86d9edd896da39;p=sven%2Fmpt-status.git Port some of the obvious non-rhel compatible commands and functions. --- diff --git a/mpt-status.init b/mpt-status.init index 922442c..65b2e79 100644 --- a/mpt-status.init +++ b/mpt-status.init @@ -2,7 +2,13 @@ # Author: Petter Reinholdtsen # License: GNU General Public License v2 or later + +# mpt-statusd - Check mpt-status values in the background. # +# chkconfig: 345 60 50 +# description: Check mpt-status values in the background \ +# using daemonize and the mpt-status utility. + ### BEGIN INIT INFO # Provides: mpt-statusd # Required-Start: $remote_fs $syslog @@ -32,20 +38,19 @@ ID=0 # Gracefully exit if the package has been removed. test -x /usr/sbin/mpt-status || exit 0 +# Source function library. +. /etc/rc.d/init.d/functions . /lib/lsb/init-functions -[ -e /etc/default/rcS ] && . /etc/default/rcS if [ $RUN_DAEMON = "no" ] ; then - log_begin_msg "mpt-statusd is disabled in /etc/default/mpt-statusd, not starting." - log_end_msg 0 + log_failure_msg $"mpt-statusd is disabled in /etc/default/mpt-statusd, not starting." exit 0 fi -if ! [ -e "/proc/mpt/version" ] ; then - log_failure_msg "The mptctl module is missing. Please have a look at the README.Debian.gz." - log_end_msg 0 - exit 0 -fi +#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 @@ -127,15 +132,14 @@ check_daemon() { d_start() { [ -f $PIDFILE ] && PID="`cat $PIDFILE`" if [ "$PID" ] ; then - log_progress_msg "Daemon already running. Refusing to start another" + log_warning_msg "Daemon already running. Refusing to start another" return 0 elif check_daemon ; then - # Use the daemon package to turn this script into a daemon - start-stop-daemon --start --quiet --pidfile $PIDFILE \ - --oknodo --exec /usr/bin/daemon /usr/bin/daemon $SCRIPTNAME check_mpt + # Use daemonize to turn it into a daemon and start it with daemon(). + daemon --pidfile $PIDFILE /usr/sbin/daemonize $SCRIPTNAME check_mpt return 0 else - log_progress_msg "Daemon is already running. Refusing to start another" + log_warning_msg "Daemon is already running. Refusing to start another" return 0 fi } @@ -145,10 +149,10 @@ d_start() { # d_stop() { if [ -f $PIDFILE ] ; then - start-stop-daemon --stop --oknodo --quiet --pidfile $PIDFILE > /dev/null 2>&1 + killproc -p $PIDFILE $SCRIPTNAME > /dev/null 2>&1 rm -f $PIDFILE else - log_progress_msg "Daemon is already stopped." + log_warning_msg "Daemon is already stopped." return 0 fi } @@ -157,39 +161,33 @@ d_stop() { # therefore can be used by a restart d_stop_by_restart() { if [ -f $PIDFILE ] ; then - start-stop-daemon --oknodo --stop --quiet --pidfile $PIDFILE + killproc -p $PIDFILE $SCRIPTNAME > /dev/null 2>&1 rm -f $PIDFILE - log_end_msg 0 else - log_progress_msg "Daemon is already stopped." - log_end_msg 0 + log_warning_msg "Daemon is already stopped." fi } case "$1" in start) echo -n "" - log_begin_msg "Starting $DESC: $NAME" - d_start ; CODE=$? - log_end_msg $CODE + echo -n $"Starting $DESC: $NAME" + d_start ;; stop) log_begin_msg "Stopping $DESC: $NAME" - d_stop ; CODE=$? - log_end_msg $CODE + d_stop ;; check_mpt) check_mpt ;; restart|force-reload) - log_begin_msg "Restarting $DESC: $NAME" + echo -n "Restarting $DESC: $NAME" d_stop_by_restart sleep 1 - d_start || CODE=$? - log_end_msg $CODE + d_start ;; *) - # echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 1 ;;