#!/bin/sh
#
-# chkconfig: 2345 05 92
+# chkconfig: 2345 35 65
# description: apmd is used for monitoring batery status and logging it via \
# syslog(8). It can also be used for shutting down the machine when \
# the battery is low.
# Source function library.
. /etc/rc.d/init.d/functions
-if [ ! -f /proc/apm ]; then
- echo "No kernel APM support!"
- exit 1
+no_kernel_supp() {
+ echo $(nls "No kernel APM support")'!'
+ exit 1
+}
+
+if [ ! -f /proc/apm ]; then
+ modprobe apm || no_kernel_supp
fi
CONFIG=/etc/sysconfig/apmd
+RETVAL=0
# See how we were called.
case "$1" in
start)
- msg_starting APM
- [ -r "$CONFIG" ] && . "$CONFIG"
- daemon /usr/sbin/apmd "$APMD_OPTIONS"
- touch /var/lock/subsys/apmd
+ # Check if the service is already running?
+ if [ ! -f /var/lock/subsys/apmd ]; then
+ msg_starting APM
+ [ -r "$CONFIG" ] && . "$CONFIG"
+ daemon apmd "$APMD_OPTIONS"
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/apmd
+ else
+ msg_already_running APM
+ fi
;;
stop)
- msg_stopping APM
- killproc apmd
- rm -f /var/lock/subsys/apmd
+ if [ -f /var/lock/subsys/apmd ]; then
+ msg_stopping APM
+ killproc apmd
+ rm -f /var/lock/subsys/apmd
+ else
+ msg_not_running APM
+ fi
;;
status)
status apmd
+ exit $?
;;
- restart|reload)
+ restart|force-reload)
$0 stop
$0 start
+ exit $?
;;
*)
- msg_Usage "$0 {start|stop|status|restart|reload}"
- exit 1
+ msg_usage "$0 {start|stop|restart|force-reload|status}"
+ exit 3
esac
+
+exit $RETVAL