packages: libcgroup/cgred.init - pldizer was here :D ps: what is flash? one...

glen glen at pld-linux.org
Tue Feb 8 16:07:23 CET 2011


Author: glen                         Date: Tue Feb  8 15:07:23 2011 GMT
Module: packages                      Tag: HEAD
---- Log message:
- pldizer was here :D
ps: what is flash? one wanted flush?

---- Files affected:
packages/libcgroup:
   cgred.init (1.3 -> 1.4) 

---- Diffs:

================================================================
Index: packages/libcgroup/cgred.init
diff -u packages/libcgroup/cgred.init:1.3 packages/libcgroup/cgred.init:1.4
--- packages/libcgroup/cgred.init:1.3	Tue Feb  8 15:55:38 2011
+++ packages/libcgroup/cgred.init	Tue Feb  8 16:07:17 2011
@@ -13,23 +13,26 @@
 . /etc/rc.d/init.d/functions
 
 start() {
-	if [ -f "/var/lock/subsys/cgred" ] ; then
+	if [ -f /var/lock/subsys/cgred ]; then
 		msg_already_running "CGroup Rules Engine Daemon"
 		return
 	fi
 
 	if [ ! -s /etc/cgrules.conf ]; then
 		nls "CGroup Rules Engine Daemon not configured"
-		return 6
+		RETVAL=6
+		return
 	fi
-	if ! grep -qs "^cgroup" /proc/mounts ; then
+	if ! grep -qs "^cgroup" /proc/mounts; then
 		nls "Cannot find cgroups, is cgconfig service running?"
-		return 1
+		RETVAL=1
+		return
 	fi
+
 	msg_staring "CGroup Rules Engine Daemon"
 	# Read in configuration options.
 	OPTIONS=""
-	if [ -f "/etc/sysconfig/cgred.conf" ] ; then
+	if [ -f /etc/sysconfig/cgred.conf ]; then
 		. /etc/sysconfig/cgred.conf
 
 		OPTIONS="$NODAEMON $LOG"
@@ -44,21 +47,49 @@
 		return 7
 	fi
 	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/cgred
-	echo "`pidof cgrulesengd`" > /var/run/cgred.pid
+	pidof cgrulesengd > /var/run/cgred.pid
 }
 
 stop() {
-	if [ -f /var/lock/subsys/cgred ]; then
-		msg_stopping "CGroup Rules Engine Daemon"
-		killproc -p /var/run/cgred.pid cgrulesengd -TERM
-		RETVAL=$?
-		if [ $RETVAL -eq 0 ] ; then
-			rm -f /var/lock/subsys/cgred
-			rm -f /var/run/cgred.pid
-		fi
-	else
+	if [ ! -f /var/lock/subsys/cgred ]; then
 		msg_not_running "CGroup Rules Engine Daemon"
+		return
+	fi
+
+	msg_stopping "CGroup Rules Engine Daemon"
+	killproc -p /var/run/cgred.pid cgrulesengd -TERM
+	RETVAL=$?
+	if [ $RETVAL -eq 0 ] ; then
+		rm -f /var/lock/subsys/cgred /var/run/cgred.pid
+	fi
+}
+
+reload() {
+	if [ ! -f /var/lock/subsys/cgred ] ; then
+		msg_not_running "cgred"
+		return
+	fi
+
+	show "Reloading rules configuration..."
+	# SIGUSR2
+	kill -s 12 $(cat ${pidfile})
+	RETVAL=$?
+	if [ $RETVAL -eq 0 ]; then
+		fail
+	else
+		ok
+	fi
+}
+
+condrestart() {
+	if [ ! -f /var/lock/subsys/cgred ]; then
+		msg_not_running "cgred"
+		RETVAL=$1
+		return
 	fi
+
+	stop
+	start
 }
 
 RETVAL=0
@@ -66,43 +97,29 @@
 case "$1" in
   start)
 	start
-	RETVAL=$?
 	;;
   stop)
 	stop
-	RETVAL=$?
-	;;
-  status)
-	status -p /var/run/cgred.pid cgred
-	RETVAL=$?
 	;;
   restart)
 	stop
 	start
 	;;
-  condrestart)
-	if [ -f /var/lock/subsys/cgred ] ; then
-		stop
-		start
-	fi
-	;;
   reload|flash)
-	if [ -f /var/lock/subsys/cgred ] ; then
-		show "Reloading rules configuration..."
-		# SIGUSR2
-		kill -s 12 `cat ${pidfile}`
-		RETVAL=$?
-		if [ $RETVAL -eq 0 ] ; then
-			fail
-		else
-			ok
-		fi
-	else
-		msg_not_running "cgred"
-	fi
+  	reload
+	;;
+  try-restart)
+	condrestart 0
+	;;
+  force-reload)
+	condrestart 7
+	;;
+  status)
+	status -p /var/run/cgred.pid cgred
+	RETVAL=$?
 	;;
   *)
-	msg_usage "$0 {start|stop|status|restart|condrestart|reload}"
+	msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
 	exit 3
 	;;
 esac
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/libcgroup/cgred.init?r1=1.3&r2=1.4&f=u



More information about the pld-cvs-commit mailing list