#!/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() { if [ -f /etc/cgrules.conf ]; then defaultcgroup=$(awk '/^\*[\t ]+/ { print $3; exit }' /etc/cgrules.conf) if [ -n "$defaultcgroup" -a "$defaultcgroup" = "*" ]; then nls "/etc/cgrules.conf incorrect" nls "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 nls "/etc/cgconfig.conf is not configured" return 6 fi /sbin/cgconfigparser -l /etc/cgconfig.conf retval=$? if [ $retval -ne 0 ]; then nls "Failed to parse /etc/cgconfig.conf" return 1 fi if is_yes "$CREATE_DEFAULT"; then create_default_groups fi retval=$? [ $retval -eq 0 ] && touch /var/lock/subsys/cgconfig 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