-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcreate_cgexec
More file actions
executable file
·44 lines (34 loc) · 819 Bytes
/
create_cgexec
File metadata and controls
executable file
·44 lines (34 loc) · 819 Bytes
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
#!/bin/bash
#write by shuali
cgarg=$1
tmpfile=$(mktemp)
execstr=$2
echo $cgarg | tr " " "\n" | sort >$tmpfile
error_message()
{
echo $1
exit $2
}
uuid || yum install -y uuid ||apt-get install -y uuid
gro=$(uuid |awk -F '-' '{print $1}')
for i in $(cat $tmpfile)
do
value=${i##*=}
j=${i%%=*}
subsys=${j%%.*}
pro=${j#*.}
cgget -g $subsys / |grep -q "$subsys.$pro:" || error_message "$subsys.$pro is not found in $subsys" 23
done
for i in $(cat $tmpfile)
do
value=${i##*=}
j=${i%%=*}
subsys=${j%%.*}
pro=${j#*.}
#echo subsys=$subsys pro=$pro value=$value
cgcreate -g $subsys:$gro
cgset -r $subsys.$pro=$value /$gro
done
arg=$(cat $tmpfile | awk -F '.' '{print $1}'|uniq|awk -v gro="$gro" -F '.' '{print "-g "$1":"gro}')
cgexec $arg --sticky $execstr
rm $tmpfile