This repository has been archived on 2024-11-07. You can view files and clone it, but cannot push or open issues or pull requests.
apmd/apmd-initscript

90 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

#!/bin/bash
#
# /etc/rc.d/init.d/apm
#
# Starts the apm daemon
#
# chkconfig: 345 44 56
# description: Listen and dispatch APM events from the kernel
# processname: apmd
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/apm ]; then
source /etc/sysconfig/apm
fi
DAEMON=apm
PROGNAME=${DAEMON}d
test -x /usr/sbin/$PROGNAME || exit 0
RETVAL=0
#
# See how we were called.
#
start() {
# Check if it is already running
if [[ ! -f /var/lock/subsys/$PROGNAME && ! -e /proc/acpi && -e /proc/apm ]]; then
echo -n "Starting $DAEMON daemon: "
daemon /usr/sbin/$PROGNAME
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$PROGNAME
echo
fi
return $RETVAL
}
stop() {
if [[ ! -f /var/lock/subsys/$PROGNAME ]]; then
echo -n "Stopping $DAEMON daemon: "
killproc /usr/sbin/$PROGNAME
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$PROGNAME
echo
fi
return $RETVAL
}
restart() {
stop
start
}
reload() {
trap "" SIGHUP
killall -HUP $PROGNAME
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
condrestart)
if [ -f /var/lock/subsys/$PROGNAME ]; then
restart
fi
;;
status)
status $PROGNAME
;;
*)
INITNAME=`basename $0`
echo "Usage: $INITNAME {start|stop|restart|condrestart|status}"
exit 1
esac
exit $RETVAL