#!/bin/bash
# Copyright Atomicorp, 2007-2009
# Licens: GPLv3 
# Init file for PSMON 
# Version 0.1

# chkconfig: 35 99 10
# 
# description: PSMON init script
# processname: psmon
# config: /etc/psmon.conf

# source function library
. /etc/rc.d/init.d/functions
prog=psmon
binary=/usr/bin/psmon
OPTIONS="--daemon --cron 2>/dev/null"

RETVAL=0


start()
{
	if [ -f /var/lock/subsys/psmon ]; then
          echo -n $"Stopping $prog: "
          killproc $binary
	fi
 

	echo -n $"Starting $prog: "
	daemon $binary $OPTIONS 
	RETVAL=$?

        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/psmon

	echo
        return $RETVAL

}

stop()
{
	echo -n $"Stopping $prog: "
	killproc $binary
	RETVAL=$?

        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/psmon

	echo
        return $RETVAL

}



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

