SOURCES: pommed.init - better, thx glen

shadzik shadzik at pld-linux.org
Thu Dec 20 19:28:36 CET 2007


Author: shadzik                      Date: Thu Dec 20 18:28:36 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- better, thx glen

---- Files affected:
SOURCES:
   pommed.init (1.2 -> 1.3) 

---- Diffs:

================================================================
Index: SOURCES/pommed.init
diff -u SOURCES/pommed.init:1.2 SOURCES/pommed.init:1.3
--- SOURCES/pommed.init:1.2	Thu Dec 20 19:09:39 2007
+++ SOURCES/pommed.init	Thu Dec 20 19:28:30 2007
@@ -1,63 +1,81 @@
 #!/bin/sh
 #
-# chkconfig: 2345 88 12
+# pommed	pommed
+#
+# chkconfig:	345 88 12
+#
+# description:	pommed
+#
+# $Id$
+
+# Source function library
+. /etc/rc.d/init.d/functions
 
 # We can't run without acpi:
 [ -e /proc/acpi ] || exit
 
-# Source function library.
-. /etc/init.d/functions
-
-RETVAL=0
-
 start() {
-	msg_starting "Pommed"
-	daemon /usr/sbin/pommed
-	touch /var/lock/subsys/pommed
+	# Check if the service is already running?
+	if [ ! -f /var/lock/subsys/pommed ]; then
+		msg_starting pommed
+		daemon pommed
+		RETVAL=$?
+		[ $RETVAL -eq 0 ] && touch /var/lock/subsys/pommed
+	else
+		msg_already_running pommed
+	fi
 }
 
 stop() {
-	msg_stopping "Pommed"
-	killproc pommed
-	RETVAL=$?
-	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/pommed
-}
-
-dostatus() {
-	status pommed
-	RETVAL=$?
-}
-
-restart() {
-	stop
-	start
-	RETVAL=$?
+	if [ -f /var/lock/subsys/pommed ]; then
+		# Stop daemons.
+		msg_stopping pommed
+		killproc pommed
+		rm -f /var/lock/subsys/pommed
+	else
+		msg_not_running pommed
+	fi
 }
 
-condrestart() {
-	[ -e /var/lock/subsys/pommed ] && restart || :
+reload() {
+	if [ -f /var/lock/subsys/pommed ]; then
+		msg_reloading pommed
+		killproc pommed -HUP
+		RETVAL=$?
+	else
+		msg_not_running pommed
+		RETVAL=7
+	fi
 }
 
+RETVAL=0
 # See how we were called.
 case "$1" in
   start)
-	start
+  	start
 	;;
   stop)
+  	stop
+	;;
+  restart)
 	stop
+	start
 	;;
-  status)
-	dostatus
+  reload)
+  	reload
 	;;
-  restart|reload)
-	restart
+# ONLY if program allows reloading without stopping
+# otherwise include force-reload with 'reload'
+  force-reload)
+	reload
 	;;
-  condrestart)
-	condrestart
+  status)
+	status pommed
+	RETVAL=$?
 	;;
   *)
-	msg_usage "$0 {start|stop|status|restart|reload|condrestart}"
-	exit 1
+	msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
+	exit 3
 esac
 
 exit $RETVAL
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/pommed.init?r1=1.2&r2=1.3&f=u



More information about the pld-cvs-commit mailing list