]> git.pld-linux.org Git - packages/apmd.git/blobdiff - apmd.init
- release 5
[packages/apmd.git] / apmd.init
index a9bebe750a06b76ece37c5771e9d294bd1aab3f4..a46d2b7493da80ca0b360b49b9214e3e5043d126 100644 (file)
--- a/apmd.init
+++ b/apmd.init
@@ -1,40 +1,62 @@
 #!/bin/sh
 #
-# chkconfig: 2345 05 92
-# 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.
-# processname: apmd
-# config: /etc/sysconfig/apmd
+# 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.
+# processname: apmd
+# config:      /etc/sysconfig/apmd
 
-CONFIG=/etc/sysconfig/apmd
 # Source function library.
 . /etc/rc.d/init.d/functions
 
+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)
-       echo -n "Starting up APM daemon: "
-       test -r "$CONFIG" && . "$CONFIG"
-       daemon /usr/sbin/apmd "$APMD_OPTIONS"
-       touch /var/lock/subsys/apmd
-       echo
+       # 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)
-       echo -n "Shutting down APM daemon: "
-       killproc apmd
-       rm -f /var/lock/subsys/apmd
-       echo
+       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 $?
        ;;
-       
   *)
-       echo "Usage: apmd.init {start|stop|status|restart|reload}"
-       exit 1
+       msg_usage "$0 {start|stop|restart|force-reload|status}"
+       exit 3
 esac
+
+exit $RETVAL
This page took 0.090292 seconds and 4 git commands to generate.