#!/bin/bash
#
#	/etc/rc.d/init.d/epson_pcsvcd
#
# Starts the at daemon
#
# chkconfig: 3456 20 80
# description: EPSON Port Communication Service
# processname: portcommunicationserviced

. /etc/init.d/functions

# export PCS_SETTING_DIR=
# export PCS_INSTALL_DIR=

PCSVCD_BIN="portcommunicationserviced"
DESC="EPSON Port Communication Service"

test -x /usr/sbin/$PCSVCD_BIN || exit 0

RETVAL=0


start() {
	echo -n "Starting $DESC"
	col=$COLUMNS-30
	for (( i=1;i<$col;i++ ))
	do 
		echo -n " "
	done					
	/usr/sbin/$PCSVCD_BIN &
	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 $DESC"
	col=$COLUMNS-30	
	for ((i=1;i<$col;i++ ))
	do 
		echo -n " "
	done					
	killall -15 --quiet /usr/sbin/$PCSVCD_BIN &
	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}"
	exit 1
esac

exit $?
exit $RETVAL
