Sophie

Sophie

distrib > Mandriva > current > i586 > media > contrib-release-src > by-pkgid > 7d4972a7096b7d44f1a4bcc303ef5962 > files > 2

monitorix-1.2.0-3mdv2010.1.src.rpm

#!/bin/bash
#
# @(#) Fibranet NSP, SL
# Copyright (C) 2005-2008 by Jordi Sanfeliu <admin@fibranet.cat>
#
#	/etc/rc.d/init.d/monitorix
#
# Starts Monitorix on RedHat/Fedora/CentOS Linux systems
#
# chkconfig: 2345 99 10
# description: lightweight system monitoring tool

# Source function library.
. /etc/init.d/functions

RETVAL=0
LOCK="/var/lock/monitorix"
PROGRAM="Monitorix"

start() {
	# Check if monitorix is already running
	gprintf "Starting %s:" "$PROGRAM"
	if [ ! -f "$LOCK" ]; then
                touch $LOCK
	else
		echo_failure
		echo
		return $RETVAL
	fi

	# Creates RRDs files (if needed)
	/usr/sbin/monitorix.pl create
	if [ $? -gt 0 ]; then
		echo_failure
		echo
		return $RETVAL
	fi
	/usr/sbin/monitorix.pl init
	if [ $? -eq 0 ]; then
		echo_success
	else
		echo_failure
		return $RETVAL
	fi
	echo
}

stop() {
	gprintf "Stopping %s:" "$PROGRAM"
	if [ -e $LOCK ] ; then
		rm -f $LOCK
		/usr/sbin/monitorix.pl stop
		if [ $? -gt 0 ]; then
			echo_failure
			echo
			return $RETVAL
		else
			echo_success
		fi
	else
		echo_failure
	fi
	echo
}

status() {
        if [ -e $LOCK ] ; then
                echo $"$PROGRAM is running."
        else
                echo $"$PROGRAM is stopped."
        fi
}

case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	status)
		status
		;;
	restart)
		stop
		sleep 1
		start
		;;
	*)
		echo $"Usage: $0 {start|stop|status|restart}"
		exit 1
esac

exit $RETVAL