add run_in_cgroup script for other easy use

This commit is contained in:
fancy
2020-04-22 16:12:06 +08:00
parent e94e413aee
commit a4c5d8f433
3 changed files with 59 additions and 5 deletions

View File

@@ -5,8 +5,12 @@ source $config
# test suid bit
if [ -u "$(which cgattach)" ]; then
cgattach $$ $proxy_cgroup
cgattach $$ $proxy_cgroup && attached=1
else
sudo cgattach $$ $proxy_cgroup
sudo cgattach $$ $proxy_cgroup && attached=1
fi
$@
# test attach success or not
[[ -z "$attached" ]] && echo "config error" && exit 1
exec "$@"