3 # cgconfig Control Groups Configuration Startup
5 # description: This script runs the cgconfigparser utility to parse and setup \
6 # the control group filesystem. It uses /etc/cgconfig.conf \
7 # and parses the configuration specified in there.
9 # Source function library
10 . /etc/rc.d/init.d/functions
14 [ -f /etc/sysconfig/cgconfig ] && . /etc/sysconfig/cgconfig
16 create_default_groups() {
17 if [ -f /etc/cgrules.conf ]; then
18 defaultcgroup=$(awk '/^\*[\t ]+/ { print $3; exit }' /etc/cgrules.conf)
19 if [ -n "$defaultcgroup" -a "$defaultcgroup" = "*" ]; then
20 # nls "/etc/cgrules.conf incorrect. Overriding it"
25 if [ -z $defaultcgroup ]; then
26 defaultcgroup=sysdefault/
30 # Find all mounted subsystems and create comma-separated list
33 controllers=`lssubsys 2>/dev/null | awk '{ if (v) v=v","$0 ; else v=$0 } END { printf v }'`
36 # Create the default group, ignore errors when the default group
39 cgcreate -f 664 -d 775 -g $controllers:$defaultcgroup 2>/dev/null
42 # special rule for cpusets
44 if echo $controllers | grep -q -w cpuset; then
45 cpus=`cgget -nv -r cpuset.cpus /`
46 cgset -r cpuset.cpus=$cpus $defaultcgroup
47 mems=`cgget -nv -r cpuset.mems /`
48 cgset -r cpuset.mems=$mems $defaultcgroup
52 # Classify everything to default cgroup. Ignore errors, some processes
53 # may exit after ps is run and before cgclassify moves them.
55 cgclassify -g $controllers:$defaultcgroup `ps --no-headers -eL o tid` 2>/dev/null || :
59 # Check if the service is already running?
60 if [ -f /var/lock/subsys/cgconfig ]; then
61 msg_already_running "cgconfig"
64 if [ ! -s /etc/cgconfig.conf ]; then
65 nls "/etc/cgconfig.conf is not configured"
68 msg_starting "cgconfig"; busy
70 out=`/sbin/cgconfigparser -l /etc/cgconfig.conf 2>&1`
72 if [ $RETVAL -ne 0 ]; then
74 [ "$out" ] && echo >&2 "$out"
78 if is_yes "$CREATE_DEFAULT"; then
82 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/cgconfig
87 if [ -f /var/lock/subsys/cgconfig ]; then
88 msg_stopping "cgconfig"
90 rm -f /var/lock/subsys/cgconfig
93 msg_not_running "cgconfig"
111 if [ -f /var/lock/subsys/cgconfig ] ; then
117 if [ -f /var/lock/subsys/cgconfig ] ; then
126 msg_usage "$0 {start|stop|restart|condrestart|status}"