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

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

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

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

# Read EPSONPHLOGD config	
#. $EPSONPHLOGD_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 epuraslogd "
		startproc $EPSONPHLOGD_BIN

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

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