blob: e1c60daaf4bb686e17a54722cd9eb6dd7eb7c1ab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
#!/bin/sh
#
# cgconfig Control Groups Configuration Startup
# chkconfig: 2345 01 99
# 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 controllers
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. 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 | awk '{ if (v) v=v","$0 ; else v=$0 } END { printf "%s", v }')
#
# 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
local cpus mems
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
if [ ! -s /etc/cgconfig.conf ]; then
nls "/etc/cgconfig.conf is not configured"
RETVAL=6
return
fi
msg_starting "cgconfig"; busy
local out
out=$(/sbin/cgconfigparser -l /etc/cgconfig.conf 2>&1)
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
fail
[ "$out" ] && echo >&2 "$out"
exit $RETVAL
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_not_running "cgconfig"
return
fi
msg_stopping "cgconfig"
cgclear
cgclear
rm -f /var/lock/subsys/cgconfig
ok
}
condrestart() {
if [ ! -f /var/lock/subsys/cgconfig ]; then
msg_not_running "cgconfig"
RETVAL=$1
return
fi
stop
start
}
RETVAL=0
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
try-restart)
condrestart 0
;;
force-reload)
condrestart 7
;;
status)
if [ -f /var/lock/subsys/cgconfig ] ; then
echo "Running"
exit 0
else
echo "Stopped"
exit 3
fi
;;
*)
msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
exit 3
;;
esac
exit $RETVAL
|