#!/bin/sh
# $Id: template,v 1.3 2003/05/21 17:47:00 ldv Exp $
#
# atieventsd - The ATI External Events Daemon
#
# chkconfig: - 45 65
# description:  Listen and dispatch ACPI \
#		events from the kernel
#		
# processname: atieventsd
# pidfile: /var/run/atieventsd.pid
# Do not load RH compatibility interface.

### BEGIN INIT INFO
# Provides: atieventsd
# Required-Start: $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description:control ATI external events daemon
# Description:  Starts or stops the ATI external events daemon,
#               which handles power management for fglrx-driver.
### END INIT INFO


WITHOUT_RC_COMPAT=1

# Source function library.
. /etc/init.d/functions

LOCKFILE=/var/lock/subsys/atieventsd
RETVAL=0
DAEMONOPTS=""

start()
{
	start_daemon --lockfile "$LOCKFILE" --expect-user root -- atieventsd $DAEMONOPTS
	RETVAL=$?
	return $RETVAL
}

stop()
{
	stop_daemon --lockfile "$LOCKFILE" --expect-user root -- atieventsd
	RETVAL=$?
	return $RETVAL
	rm -f $PIDFILE
}

restart()
{
	stop
	start
}

# See how we were called.
case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart|reload)
		restart
		;;
	condstop)
		if [ -e "$LOCKFILE" ]; then
			stop
		fi
		;;
	condrestart|condreload)
		if [ -e "$LOCKFILE" ]; then
			restart
		fi
		;;
	status)
		status --expect-user root -- atieventsd
		RETVAL=$?
		;;
	*)
		msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
		RETVAL=1
esac

exit $RETVAL
