Author: baggins                      Date: Mon Feb  7 23:34:37 2011 GMT
Module: packages                      Tag: HEAD
---- Log message:
- started work on PLD init scripts

---- Files affected:
packages/libcgroup:
   cgconfig.init (NONE -> 1.1)  (NEW), cgred.init (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/libcgroup/cgconfig.init
diff -u /dev/null packages/libcgroup/cgconfig.init:1.1
--- /dev/null   Tue Feb  8 00:34:37 2011
+++ packages/libcgroup/cgconfig.init    Tue Feb  8 00:34:31 2011
@@ -0,0 +1,139 @@
+#!/bin/sh
+#
+# cgconfig     Control Groups Configuration Startup
+# chkconfig:   - 5 95
+# description: This script runs the cgconfigparser utility to parse and setup \
+#              the control group filesystem. It uses /etc/cgconfig.conf \
+#              and parses the configuration specified in there.
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# read the config
+CREATE_DEFAULT=yes
+[ -f /etc/sysconfig/cgconfig ] && . /etc/sysconfig/cgconfig
+
+create_default_groups() {
+       local defaultcgroup
+
+        if [ -f /etc/cgrules.conf ]; then
+               defaultcgroup=$(awk '/^\*[\t ]+/ { print $3; exit }' 
/etc/cgrules.conf)
+               if [ -n "$defaultcgroup" -a "$defaultcgroup" = "*" ]; then
+                       log_warning_msg "/etc/cgrules.conf incorrect"
+                       log_warning_msg "Overriding it"
+                       defaultcgroup=
+               fi
+       fi
+
+       if [ -z $defaultcgroup ]; then
+               defaultcgroup=sysdefault/
+       fi
+
+        #
+        # Find all mounted subsystems and create comma-separated list
+        # of controllers.
+        #
+        controllers=`lssubsys 2>/dev/null | tr '\n' ',' | sed s/.$//`
+
+        #
+        # Create the default group, ignore errors when the default group
+        # already exists.
+        #
+        cgcreate -f 664 -d 775 -g $controllers:$defaultcgroup 2>/dev/null
+
+        #
+        # special rule for cpusets
+        #
+        if echo $controllers | grep -q -w cpuset; then
+                 cpus=`cgget -nv -r cpuset.cpus /`
+                 cgset -r cpuset.cpus=$cpus $defaultcgroup
+                 mems=`cgget -nv -r cpuset.mems /`
+                 cgset -r cpuset.mems=$mems $defaultcgroup
+        fi
+
+        #
+        # Classify everything to default cgroup. Ignore errors, some processes
+        # may exit after ps is run and before cgclassify moves them.
+        #
+        cgclassify -g $controllers:$defaultcgroup `ps --no-headers -eL o tid` 
2>/dev/null || :
+}
+
+start() {
+       # Check if the service is already running?
+       if [ -f /var/lock/subsys/cgconfig ]; then
+               msg_already_running "cgconfig"
+               return
+       fi
+
+       msg_starting "cgconfig"
+       if [ ! -s /etc/cgconfig.conf ]; then
+               log_failure_msg "/etc/cgconfig.conf is not configured"
+               return 6
+       fi
+
+       /sbin/cgconfigparser -l /etc/cgconfig.conf
+       retval=$?
+       if [ $retval -ne 0 ]; then
+               log_failure_msg "Failed to parse /etc/cgconfig.conf"
+               return 1
+       fi
+
+       if [ $CREATE_DEFAULT = "yes" ]; then
+               create_default_groups
+       fi
+
+       touch /var/lock/subsys/cgconfig
+       retval=$?
+       if [ $retval -ne 0 ]; then
+               log_failure_msg "Failed to touch /var/lock/subsys/cgconfig"
+               return 1
+       fi
+       ok
+}
+
+stop() {
+       if [ -f /var/lock/subsys/cgconfig ]; then
+               msg_stopping "cgconfig"
+               cgclear
+               rm -f /var/lock/subsys/cgconfig
+               ok
+       else
+               msg_not_running "cgconfig"
+       fi
+}
+
+RETVAL=0
+
+case "$1" in
+  start)
+       start
+       ;;
+  stop)
+       stop;
+       ;;
+  restart|reload)
+       stop
+       start
+       ;;
+  condrestart)
+       if [ -f /var/lock/subsys/cgconfig ] ; then
+               stop
+               start
+       fi
+       ;;
+  status)
+       if [ -f /var/lock/subsys/cgconfig ] ; then
+               echo "Running"
+               exit 0
+       else
+               echo "Stopped"
+               exit 3
+       fi
+       ;;
+  *)
+       msg_usage "$0 {start|stop|restart|condrestart|status}"
+       exit 3
+       ;;
+esac
+
+exit $RETVAL

================================================================
Index: packages/libcgroup/cgred.init
diff -u /dev/null packages/libcgroup/cgred.init:1.1
--- /dev/null   Tue Feb  8 00:34:37 2011
+++ packages/libcgroup/cgred.init       Tue Feb  8 00:34:32 2011
@@ -0,0 +1,110 @@
+#!/bin/sh
+#
+# cgred                CGroups Rules Engine Daemon
+# chkconfig:   - 14 86
+# description: This is a daemon for automatically classifying processes \
+#              into cgroups based on UID/GID.
+#
+# processname: cgrulesengd
+# pidfile:     /var/run/cgred.pid
+#
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+start() {
+       if [ -f "/var/lock/subsys/cgred" ] ; then
+               msg_already_running "CGroup Rules Engine Daemon"
+               return
+       fi
+
+       msg_staring "CGroup Rules Engine Daemon"
+       if [ ! -s /etc/cgrules.conf ]; then
+               log_failure_msg "not configured"
+               return 6
+       fi
+       if ! grep -qs "^cgroup" /proc/mounts ; then
+               log_failure_msg "Cannot find cgroups, is cgconfig service 
running?"
+               return 1
+       fi
+       # Read in configuration options.
+       OPTIONS=""
+       if [ -f "/etc/sysconfig/cgred.conf" ] ; then
+               . /etc/sysconfig/cgred.conf
+
+               OPTIONS="$NODAEMON $LOG"
+               [ -n "$LOG_FILE" ] && OPTIONS="$OPTIONS --logfile=$LOG_FILE"
+               [ -n "$SOCKET_USER" ] && OPTIONS="$OPTIONS -u $SOCKET_USER"
+               [ -n "$SOCKET_GROUP" ] && OPTIONS="$OPTIONS -g $SOCKET_GROUP"
+       fi
+
+       daemon --check cgred --pidfile /var/run/cgred.pid /sbin/cgrulesengd 
$OPTIONS
+       RETVAL=$?
+       if [ $RETVAL -ne 0 ]; then
+               return 7
+       fi
+       [ $RETVAL -eq 0 ] && touch /var/lock/subsys/cgred
+       echo "`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
+               msg_not_running "CGroup Rules Engine Daemon"
+       fi
+}
+
+RETVAL=0
+# See how we are called
+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
+       ;;
+  *)
+       msg_usage "$0 {start|stop|status|restart|condrestart|reload}"
+       exit 3
+       ;;
+esac
+
+exit $RETVAL
================================================================
_______________________________________________
pld-cvs-commit mailing list
[email protected]
http://lists.pld-linux.org/mailman/listinfo/pld-cvs-commit

Reply via email to