You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
936 B
40 lines
936 B
#!/bin/sh
|
|
|
|
function lxc-start()
|
|
{
|
|
local LXC_START=/usr/bin/lxc-start
|
|
local TEST=/usr/bin/test
|
|
local ECHO=/bin/echo
|
|
local MKDIR=/bin/mkdir
|
|
local CHOWN=/bin/chown
|
|
local SUDO=/usr/bin/sudo
|
|
local TEE=/usr/bin/tee
|
|
|
|
(
|
|
PID=$(exec /bin/sh -c 'echo $PPID')
|
|
for ctrl in /sys/fs/cgroup/*
|
|
do
|
|
${TEST} ${ctrl##*/} = 'openrc' && continue
|
|
|
|
if ${TEST} ! -d ${ctrl}/${USER}
|
|
then
|
|
${TEST} ${ctrl##*/} = 'cpuset' && \
|
|
${ECHO} 1 | ${SUDO} ${TEE} ${ctrl}/cgroup.clone_children >/dev/null
|
|
${TEST} ${ctrl##*/} = 'memory' && \
|
|
${ECHO} 1 | ${SUDO} ${TEE} ${ctrl}/memory.use_hierarchy >/dev/null
|
|
|
|
${SUDO} ${MKDIR} ${ctrl}/${USER}/
|
|
${SUDO} ${CHOWN} ${USER}: ${ctrl}/${USER}
|
|
${SUDO} ${CHOWN} ${USER}: ${ctrl}/${USER}/tasks
|
|
${SUDO} ${CHOWN} ${USER}: ${ctrl}/${USER}/cgroup.procs
|
|
fi
|
|
${ECHO} ${PID} >>"${ctrl}/${USER}/tasks"
|
|
done
|
|
|
|
${LXC_START} $@
|
|
)
|
|
}
|
|
|
|
export -f lxc-start
|
|
|
|
# vim: set ft=sh ts=4 sw=4:
|