52 lines
851 B
Bash
Executable File
52 lines
851 B
Bash
Executable File
#!/bin/sh
|
|
|
|
if [ -z $1 ];then
|
|
echo "Usage: ./set_libcgroup.sh <username>"
|
|
exit 1
|
|
fi
|
|
|
|
#设置cgconfig和cgred服务的配置文件
|
|
echo "Starting set the cgconfig.conf..."
|
|
cgconfig="group $1_limits {
|
|
perm {
|
|
task {
|
|
uid = $1;
|
|
gid = $1;
|
|
}
|
|
admin {
|
|
uid = sysadmin;
|
|
gid = sysadmin;
|
|
}
|
|
}
|
|
cpuset {
|
|
cpuset.cpus = 0-var_cpus;
|
|
cpuset.mems = var_nodes;
|
|
}
|
|
memory {
|
|
memory.limit_in_bytes = var_memM;
|
|
memory.memsw.limit_in_bytes = var_swapM;
|
|
}
|
|
cpu {
|
|
cpu.rt_runtime_us = 950000;
|
|
}
|
|
}
|
|
|
|
mount {
|
|
cpuset = /lxcg;
|
|
cpu = /lxcg;
|
|
cpuacct = /lxcg;
|
|
memory = /lxcg;
|
|
devices = /lxcg;
|
|
freezer = /lxcg;
|
|
net_cls = /lxcg;
|
|
}"
|
|
|
|
cgrules="$1: * /$1_limits"
|
|
|
|
echo "$cgconfig" > /etc/cgconfig.conf.tmp
|
|
|
|
echo "Starting set cgrules.conf..."
|
|
sed -i "/^[^#]/d" /etc/cgrules.conf
|
|
sed -i "/^$/d" /etc/cgrules.conf
|
|
echo "$cgrules" >> /etc/cgrules.conf
|