#!/bin/bash
#
#	/etc/rc.d/init.d/epurasd
#
# Starts the at daemon
#
# chkconfig: 3456 20 80
# description: Runs commands scheduled by the at command at the time \
#    specified when at was run, and runs batch commands when the load \
#    average is low enough.
# processname: epurasd

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

test -x /usr/sbin/epuraslogd || exit 0

RETVAL=0

#
#	See how we were called.
#

prog="epurasd"

start() {
	# Check if atd is already running
	echo -n "Starting epurasd "
	col=$COLUMNS-30
	for (( i=1;i<$col;i++ ))
	do 
		echo -n " "
	done					
	/usr/sbin/$prog &
	RETVAL=$?
	if [ $RETVAL -eq 0 ]; then 		
		echo -e "[ \033[0;32mOK\033[0m ]"	
	else
		echo -e "[ \033[0;31mFAILED\033[0m ]"
	fi		
}

stop() {
	echo -n "Stopping epurasd "
	col=$COLUMNS-30	
	for ((i=1;i<$col;i++ ))
	do 
		echo -n " "
	done					
	killall -9 --quiet /usr/sbin/$prog &
	echo -e "[ \033[0;32mOK\033[0m ]"	
			
}


restart() {
	stop
	start
}	

reload() {
	restart
}	


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

exit $?
exit $RETVAL
