#!/bin/bash
#
#	/etc/rc.d/init.d/epson_devicecontrollogserviced
#
# 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: devicecontrollogserviced

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

# export PCS_SETTING_DIR=
# export PCS_INSTALL_DIR=

test -x /usr/sbin/devicecontrollogserviced || exit 1

RETVAL=0

#
#	See how we were called.
#

prog="devicecontrollogserviced"

start() {
	# Check if atd is already running
	echo -n "Starting devicecontrollogserviced "
	col=$COLUMNS-35
	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 devicecontrollogserviced "
	col=$COLUMNS-35
	for (( i=1;i<$col;i++ ))
	do 
		echo -n " "
	done
	killall -15 --quiet /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
			
}

restart() {
	stop
	start
}

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

exit $RETVAL
