forked from svarshavchik/vera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrc.controllers.in
62 lines (51 loc) · 1.18 KB
/
rc.controllers.in
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
#! /bin/sh
#
# rc.S mounts all cgroups controllers in the V1 hierarchy
#
# I am rude: I will move them to the V2 hierarchy
prefix="@prefix@"
exec_prefix="@exec_prefix@"
sysconfdir="@sysconfdir@"
if test ! -f "@CONFIGDIR@/cgroup.controllers"
then
exit 0
fi
. @CONFIGDIR@/cgroup.controllers
v2controllers=""
v1controllers=""
for c in $controllers
do
v2="`echo $c | cut -d= -f1`"
v1="`echo $c | cut -d= -f2`"
v2controllers="$v2controllers $v2"
if test "$v1" = ""
then
v1="$v2"
fi
if test -d /sys/fs/cgroup/$v1
then
v1controllers="$v1controllers $v1"
if umount /sys/fs/cgroup/$v1
then
rmdir /sys/fs/cgroup/$v1
else
echo "Cannot turn off $v1 controller in cgroups version 1" >&2
fi
fi
done
# It seems that after unmounting the controller isn't immediately available
# for V2. We need to introduce an artificial delay.
if test "$v1controllers" != ""
then
echo "Stopped the following cgroups 1 controllers:$v1controllers"
sleep 2
fi
for c in $v2controllers
do
if echo "+$c" >/sys/fs/cgroup/vera/cgroup.subtree_control 2>/dev/null
then
echo "$c controller enabled"
else
echo "Cannot enable the $c controller" >&2
fi
done