#!/bin/sh
# Init file for Echelog system
#
# chkconfig: - 90 10
# description: Echelog system
#
# processname: echelogd
# config: /etc/echelog/echelog.conf

# source function library
. /etc/rc.d/init.d/functions

# Source networking configuration.
. /etc/sysconfig/network

# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0

# special environment
[ -f /etc/echelog/options ] && . /etc/echelog/options

RETVAL=0
# See how we were called.
case "$1" in
  start)
	# Start daemon.
	gprintf "Starting Echelog: "
	su - echelog -c /usr/sbin/echelogd >/dev/null 2>&1 && success || failed
	RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/echelog
	;;
  stop)
        # Stop daemons.
	gprintf "Stopping Echelog: "
	su - echelogc -c "/usr/sbin/echelogctl stop" && success; sleep 5 || failed
        RETVAL=$?
        echo
	[ $RETVAL = 0 ] && rm -f /var/lock/subsys/echelog
	;;
  restart)
        su - echelogc -c "/usr/sbin/echelogctl restart"
        RETVAL=$?
	;;
  reload)
	su - echelogc -c "/usr/sbin/echelogctl reconfigure"
	;;
  status)
	status echelog
        RETVAL=$?
	;;
  condrestart)
       [ -e /var/lock/subsys/echelog ] && $0 restart
        RETVAL=$?
       ;;
  *)
	gprintf "Usage: %s {start|stop|restart|reload|status|condrestart}\n" "$0"
	exit 1
esac

exit $RETVAL
