#!/bin/bash
#
# mmc-agent	This shell script takes care of starting and stopping
#		the Linbox Management Console agent.
#
# chkconfig: 345 40 60
# description: mmc-agent - Linbox Management Console agent.
# probe: false
# processname: mmc-agent
# pidfile: /var/run/mmc-agent.pid

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

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ "${NETWORKING}" = "no" ] && exit 0

[ -f /usr/sbin/mmc-agent ] || exit 0

if [ -f /etc/sysconfig/mmc-agent ]; then
    . /etc/sysconfig/mmc-agent
fi

RETVAL=0
OPTIONS=""

start() {
        gprintf "Starting mmc-agent: "
        daemon mmc-agent $OPTIONS
        RETVAL=$?
	echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/mmc-agent
        return $RETVAL
}
stop() {
	gprintf "Stopping mmc-agent: "
	killproc mmc-agent
	RETVAL=$?
	echo
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/mmc-agent /var/run/mmc-agent.pid
}

# See how we were called.
case "$1" in
  start)
	start
	;;
  stop)
	stop
	;;
  status)
        status mmc-agent
	RETVAL=$?
	;;
  restart|reload)
	stop
	start
	;;
  condrestart)
	if [ -f /var/run/mmc-agent.pid ] ; then
		stop
		start
	fi
	;;
  *)
	gprintf "Usage: mmc-agent {start|stop|status|restart|condrestart|reload}\n"
	exit 1
esac

exit $RETVAL
