cvsdist 362041
#!/bin/bash
cvsdist 362041
#
cvsdist 362041
#	/etc/rc.d/init.d/acpid
cvsdist 362041
#
cvsdist 362041
# Starts the acpi daemon
cvsdist 362041
#
cvsdist 362041
# chkconfig: 345 44 56
cvsdist 362041
# description: Listen and dispatch ACPI events from the kernel
cvsdist 362041
# processname: acpid
cvsdist 362041
Zdenek Prikryl 20aacf
### BEGIN INIT INFO
Zdenek Prikryl 20aacf
# Provides: acpid
Zdenek Prikryl 20bfb3
# Required-Start: $syslog $local_fs
Zdenek Prikryl 20bfb3
# Required-Stop: $syslog $local_fs
Zdenek Prikryl 20bfb3
# Default-Start:  2 3 4 5
Zdenek Prikryl 20bfb3
# Default-Stop: 0 1 6
Zdenek Prikryl 20aacf
# Short-Description: start and stop acpid
Zdenek Prikryl 20aacf
# Description: Listen and dispatch ACPI events from the kernel
Zdenek Prikryl 20aacf
### END INIT INFO
Zdenek Prikryl 20aacf
cvsdist 362041
# Source function library.
cvsdist 362041
. /etc/rc.d/init.d/functions
cvsdist 362041
cvsdist 362041
RETVAL=0
cvsdist 362041
cvsdist 362041
#
cvsdist 362041
# See how we were called.
cvsdist 362041
#
cvsdist 362041
cvsdist 362041
start() {
cvsdist 362041
	# Check if it is already running
cvsdist b5f579
	if [ ! -f /var/lock/subsys/acpid ]; then
Zdenek Prikryl 3fc873
	    echo -n $"Starting acpi daemon: "	
Zdenek Prikryl 3fc873
		# Check if acpid is executable
Zdenek Prikryl 3fc873
		if [ ! -x /usr/sbin/acpid ]; then
Zdenek Prikryl 3fc873
			logger -p daemon.error -t $0 "/usr/sbin/acpid is not executable."
Zdenek Prikryl 3fc873
			echo_failure
Zdenek Prikryl 3fc873
			exit 1
Zdenek Prikryl 3fc873
		fi
Zdenek Prikryl 3fc873
		# Check for kernel support
Zdenek Prikryl 3fc873
		if [ ! -f /proc/acpi/event ]; then
Zdenek Prikryl 3fc873
			logger -p daemon.error -t $0 "need ACPI_PROC_EVENT support in kernel."
Zdenek Prikryl 3fc873
			echo_failure
Zdenek Prikryl 3fc873
			exit 1
Zdenek Prikryl 3fc873
		fi
Zdenek Prikryl 76c0dd
	    daemon /usr/sbin/acpid $@
cvsdist 362041
	    RETVAL=$?
cvsdist b5f579
	    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/acpid
cvsdist 362041
	    echo
cvsdist 362041
	fi
cvsdist 362041
	return $RETVAL
cvsdist 362041
}
cvsdist 362041
cvsdist 362041
stop() {
cvsdist b5f579
	echo -n $"Stopping acpi daemon: "
cvsdist b5f579
	killproc /usr/sbin/acpid
cvsdist 362041
	RETVAL=$?
cvsdist b5f579
	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/acpid
cvsdist 362041
	echo
Zdenek Prikryl 20aacf
    return $RETVAL
cvsdist 362041
}
cvsdist 362041
cvsdist 362041
cvsdist 362041
restart() {
cvsdist 362041
	stop
Zdenek Prikryl 76c0dd
	start $@
cvsdist 362041
}	
cvsdist 362041
cvsdist 362041
reload() {
cvsdist 362041
	trap "" SIGHUP
Zdenek Prikryl 20aacf
	action $"Reloading acpi daemon:" killall -HUP acpid
Zdenek Prikryl 20aacf
	RETVAL=$?
Zdenek Prikryl 20aacf
	return $RETVAL
cvsdist 362041
}	
cvsdist 362041
cvsdist 362041
case "$1" in
cvsdist 362041
start)
Zdenek Prikryl 76c0dd
	start $2
cvsdist 362041
	;;
cvsdist 362041
stop)
cvsdist 362041
	stop
cvsdist 362041
	;;
cvsdist 362041
reload)
cvsdist 362041
	reload
cvsdist 362041
	;;
Zdenek Prikryl 20aacf
force-reload)
Zdenek Prikryl 20aacf
	echo "$0: Unimplemented feature."
Zdenek Prikryl 20aacf
	RETVAL=3
Zdenek Prikryl 20aacf
	;;
cvsdist 362041
restart)
Zdenek Prikryl 76c0dd
	restart $2
cvsdist 362041
	;;
cvsdist 362041
condrestart)
cvsdist b5f579
	if [ -f /var/lock/subsys/acpid ]; then
Zdenek Prikryl 76c0dd
	    restart $2
cvsdist 362041
	fi
cvsdist 362041
	;;
cvsdist 362041
status)
cvsdist b5f579
	status acpid
Zdenek Prikryl 20aacf
	RETVAL=$?
cvsdist 362041
	;;
cvsdist 362041
*)
Zdenek Prikryl 20aacf
	echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}"
Zdenek Prikryl 20aacf
	RETVAL=2
cvsdist 362041
esac
cvsdist 362041
cvsdist 362041
exit $RETVAL