commit ef7d0d5b5a8a456ac443498bfd5f2e5e421018ed parent 9c80aa3cced8658b0ebbccbe8ffcdcf78a5e1fef Author: Jan Pobrislo <ccx@webprojekty.cz> Date: Thu, 2 Sep 2021 16:35:49 +0200 Create cgroups for containers Diffstat:
M | service_scripts/generic/run | | | 10 | ++++++++++ |
M | service_scripts/xsession/run | | | 10 | ++++++++++ |
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/service_scripts/generic/run b/service_scripts/generic/run @@ -13,6 +13,16 @@ multisubstitute { # define CONTAINER_DATA /mnt/volumes/containers/user/${CONTAINER_USER}/${CONTAINER_NAME} define -s tmpfs_dirs "home run tmp inbox run/inbox tmp/.X11-unix" } + +getpid NS_PID +foreground { + importas -i NS_PID NS_PID + if { test -d /run/cgroup2 } + if { mkdir -p /run/cgroup2/containers/${CONTAINER_USER}/${CONTAINER_NAME} } + redirfd -w 1 /run/cgroup2/containers/${CONTAINER_USER}/${CONTAINER_NAME}/cgroup.procs + printf "%s" ${NS_PID} +} + if { rm -rf ${CONTAINER_TMPFS} } if { mkdir -p ${CONTAINER_TMPFS}/${tmpfs_dirs} } if { chmod 1770 ${CONTAINER_TMPFS}/${tmpfs_dirs} } diff --git a/service_scripts/xsession/run b/service_scripts/xsession/run @@ -12,6 +12,16 @@ multisubstitute { # define CONTAINER_DATA /mnt/volumes/containers/user/${CONTAINER_USER}/${CONTAINER_NAME} define -s tmpfs_dirs "home run tmp inbox run/inbox tmp/.X11-unix" } + +getpid NS_PID +foreground { + importas -i NS_PID NS_PID + if { test -d /run/cgroup2 } + if { mkdir -p /run/cgroup2/containers/${CONTAINER_USER}/${CONTAINER_NAME} } + redirfd -w 1 /run/cgroup2/containers/${CONTAINER_USER}/${CONTAINER_NAME}/cgroup.procs + printf "%s" ${NS_PID} +} + if { rm -rf ${CONTAINER_TMPFS} } if { mkdir -p ${CONTAINER_TMPFS}/${tmpfs_dirs} } if { chmod 1770 ${CONTAINER_TMPFS}/${tmpfs_dirs} }