#!/bin/sh
# Author: Edge
# 
# This file:
# /etc/init.d/epurasd
#
# Log Daemon:
# /opt/epson/epuras/epurasd
# Symbolic link of the epuras Daemon:
# /usr/sbin/epurasd

### BEGIN INIT INFO
# Provides:          epurasd
# Required-Start:    $syslog
# Required-Stop:     $syslog
# Default-Start:     1 2 3 4 5 6
# Default-Stop:      0 
# Short-Description: EPSON epuras Daemon
# Description:       EPSON epuras Daemon
### END INIT INFO

# Check for missing binaries
EPSONPHD_BIN=/usr/sbin/epurasd
test -x $EPSONPHD_BIN || { echo "$EPSONPHD_BIN not installed";
	if [ "$1" = "stop" ]; then exit 0;
	else exit 5; fi; }

# Check for existence of needed config file and read it
#EPSONPHGD_CONFIG=/etc/sysconfig/epurasd.cfg
#test -r $EPSONPHD_CONFIG || { echo "$EPSONPHD_CONFIG not existing";
#	if [ "$1" = "stop" ]; then exit 0;
#	else exit 6; fi; }

# Read epsonphd config	
#. $EPSONPHD_CONFIG

# Load the rc.status script for this service.
. /etc/rc.status

# Reset the status of this service
rc_reset

case "$1" in
	start)
		echo -n "Starting epurasd "
		startproc $EPSONPHD_BIN

		# Remember status and be verbose
		rc_status -v
		;;
	stop)
		echo -n "Stopping epurasd "
		killproc -TERM $EPSONPHD_BIN

		# Remember status and be verbose
		rc_status -v
		;;
	restart)
		echo -n "Restarting epurasd "
		$0 stop
		$0 start
		
		# Remember status
		rc_status
		;;
	reload)
		echo -n "Restarting epurasd "
		$0 stop
		$0 start
		
		# Remember status
		rc_status
		;;
	status)
		echo -n "Retrieving epurasd status "
		checkproc $EPSONPHD_BIN
		rc_status -v
		;;
	*)
	echo "Usage: $0 {start|stop|status|restart|reload}"
	exit 1
	;;
esac
rc_exit
