#!/bin/sh
#
# atsar		This shell script takes care of initializing
#		the atsar system activity report subsystem.
#
# chkconfig: 2345 85 15
# description:	Atsar is a system activity report logging system.
#

WITHOUT_RC_COMPAT=1

. /etc/init.d/functions

DAEMON=/usr/bin/atsadc
PIDFILE=/var/run/atsadc.pid
LOCKFILE=/var/lock/subsys/atsar
RETVAL=0

RETVAL=0

case "$1" in
  start)
#	echo -n "Initializing atsar logging: "
	start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" -- atsadc /var/log/atsar/atsa`date +%d`
	RETVAL=$?
        rm -f /var/log/atsar/ftpstat  2> /dev/null
        rm -f /var/log/atsar/httpstat 2> /dev/null

	if [ -f /etc/atsar.conf ]
	then
		/usr/bin/atsaftp
		/usr/bin/atsahttp
	fi
	echo
#	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/atsar
	;;
  stop)
	stop_daemon --lockfile "$LOCKFILE" -- atsadc
	RETVAL=$?
	rm -f $PIDFILE
#	rm -f /var/lock/subsys/atsar
	;;
  status)
	status -- atsadc
	RETVAL=$?
	;;
  reload)
	$0 stop
	$0 start
	;;
  restart)
	$0 stop
	$0 start
	;;
  *)
	echo "Usage: $0 {start|stop|status|reload|restart}"
	exit 1
esac

exit $RETVAL
