summaryrefslogtreecommitdiff
path: root/dev-libs/libcgroup/files
diff options
context:
space:
mode:
Diffstat (limited to 'dev-libs/libcgroup/files')
-rw-r--r--dev-libs/libcgroup/files/cgconfig.confd4
-rw-r--r--dev-libs/libcgroup/files/cgconfig.initd117
-rw-r--r--dev-libs/libcgroup/files/cgconfig.service17
-rw-r--r--dev-libs/libcgroup/files/cgred.confd17
-rw-r--r--dev-libs/libcgroup/files/cgred.initd41
-rw-r--r--dev-libs/libcgroup/files/cgrules.service16
6 files changed, 33 insertions, 179 deletions
diff --git a/dev-libs/libcgroup/files/cgconfig.confd b/dev-libs/libcgroup/files/cgconfig.confd
deleted file mode 100644
index e41730ae0ea5..000000000000
--- a/dev-libs/libcgroup/files/cgconfig.confd
+++ /dev/null
@@ -1,4 +0,0 @@
-# /etc/conf.d/cgconfig: config file for /etc/init.d/cgconfig
-
-# Configuration file location
-#CONFIG_FILE=/etc/cgroup/cgconfig.conf
diff --git a/dev-libs/libcgroup/files/cgconfig.initd b/dev-libs/libcgroup/files/cgconfig.initd
deleted file mode 100644
index f182b92ff843..000000000000
--- a/dev-libs/libcgroup/files/cgconfig.initd
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/sbin/openrc-run
-#
-# Control Groups Configuration Startup
-#
-# This script runs the cgconfigparser utility to parse and setup
-# the control group filesystem. It uses ${CONFIG_FILE}
-# and parses the configuration specified in there.
-#
-CGCONFIGPARSER="/usr/sbin/cgconfigparser"
-CGROUP_FS="cgroup"
-CONFIG_FILE=${CONFIG_FILE:-"/etc/cgroup/cgconfig.conf"}
-MOUNTS_FILE="/proc/mounts"
-RULES_FILE="/etc/cgroup/cgrules.conf"
-
-# Support multiple mount points
-MAX_INDEX=0
-declare -a MOUNT_POINTS MOUNT_OPTIONS
-
-move_all_to_init_class() {
- local i
- for i in $(seq 1 ${MAX_INDEX}); do
- cd ${MOUNT_POINTS[$i]}
-
- if grep -qw ${MOUNT_POINTS[$i]} ${MOUNTS_FILE}; then
- local directory
- for directory in $(find . -depth -type d); do
- if [[ ${directory} != "." ]]; then
- # cat fails with "Argument list too long" error
- sed -nu p < ${directory}/tasks > tasks
- rmdir ${directory}
- fi
- done
- else
- ewarn "Resource control filesystem not mounted"
- fi
-
- cd - >/dev/null
- done
-}
-
-parse_mounts() {
- local device mount_point fs_type options other
- while read device mount_point fs_type options other; do
- if grep -q ${device} <<< ${CGROUP_FS}; then
- let MAX_INDEX++
- MOUNT_POINTS[${MAX_INDEX}]=${mount_point}
- MOUNT_OPTIONS[${MAX_INDEX}]=${options}
- fi
- done < ${MOUNTS_FILE}
-}
-
-umount_fs() {
- local i
- for i in $(seq 1 ${MAX_INDEX}); do
- umount ${MOUNT_POINTS[$i]}
- rmdir ${MOUNT_POINTS[$i]}
- done
-}
-
-start() {
- ebegin "Starting cgconfig service"
-
- # Mount filesystem and create cgroups
- if ! ${CGCONFIGPARSER} -l ${CONFIG_FILE} >/dev/null; then
- eend 1 "Failed to parse ${CONFIG_FILE}"
- return 1
- fi
-
- parse_mounts
-
- # Find default cgroup name in rules file
- local default_cgroup
- if [[ -f ${RULES_FILE} ]]; then
- local user controller
- read user controller default_cgroup <<< $(grep -m1 '^\*\s' ${RULES_FILE})
- if [[ $default_cgroup == "*" ]]; then
- ewarn "${RULES_FILE} incorrect"
- ewarn "Overriding it"
- default_cgroup=
- fi
- fi
- # Use predefined name if none was found
- if [[ -z ${default_cgroup} ]]; then
- default_cgroup=sysdefault
- fi
-
- # Create a default cgroup for tasks to return back to
- local i
- for i in $(seq 1 ${MAX_INDEX}); do
- # Ignore if directory already exists
- mkdir -p ${MOUNT_POINTS[$i]}/${default_cgroup}
- find ${MOUNT_POINTS[$i]}/ -name tasks | xargs chmod a+rw
- chmod go-w ${MOUNT_POINTS[$i]}/tasks
-
- # Special rule for cpusets
- if grep -qw cpuset <<< ${MOUNT_OPTIONS[$i]}; then
- cat ${MOUNT_POINTS[$i]}/cpuset.cpus > ${MOUNT_POINTS[$i]}/${default_cgroup}/cpuset.cpus
- cat ${MOUNT_POINTS[$i]}/cpuset.mems > ${MOUNT_POINTS[$i]}/${default_cgroup}/cpuset.mems
- fi
-
- # Classify everything to default cgroup
- local j
- for j in $(ps --no-headers -eL o tid); do
- echo $j > ${MOUNT_POINTS[$i]}/${default_cgroup}/tasks 2>/dev/null
- done
- done
-
- eend 0
-}
-
-stop() {
- ebegin "Stopping cgconfig service"
- parse_mounts
- move_all_to_init_class
- umount_fs
- eend 0
-}
diff --git a/dev-libs/libcgroup/files/cgconfig.service b/dev-libs/libcgroup/files/cgconfig.service
new file mode 100644
index 000000000000..d2948ff825b7
--- /dev/null
+++ b/dev-libs/libcgroup/files/cgconfig.service
@@ -0,0 +1,17 @@
+[Unit]
+Description=Control Group configuration service
+
+# The service should be able to start as soon as possible,
+# before any 'normal' services:
+DefaultDependencies=no
+Conflicts=shutdown.target
+Before=basic.target shutdown.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ExecStart=/usr/sbin/cgconfigparser -l /etc/cgroup/cgconfig.conf -s 1664
+ExecStop=/usr/sbin/cgclear -l /etc/cgroup/cgconfig.conf -e
+
+[Install]
+WantedBy=sysinit.target
diff --git a/dev-libs/libcgroup/files/cgred.confd b/dev-libs/libcgroup/files/cgred.confd
deleted file mode 100644
index 663ffc0c7dbd..000000000000
--- a/dev-libs/libcgroup/files/cgred.confd
+++ /dev/null
@@ -1,17 +0,0 @@
-# /etc/conf.d/cgred.conf: config file for /etc/init.d/cgred
-
-# Uncomment the following line to log to specified file instead of syslog
-#LOG_FILE="/var/log/cgrulesengd.log"
-
-# Uncomment the second line to run CGroup Rules Engine in non-daemon mode
-#NODAEMON=""
-NODAEMON="--nodaemon"
-
-# Uncomment the second line to disable logging for CGroup Rules Engine
-# Uncomment the third line to enable more verbose logging.
-#LOG=""
-LOG="--nolog"
-#LOG="-v"
-
-# PID file
-PID_FILE=/var/run/cgred.pid
diff --git a/dev-libs/libcgroup/files/cgred.initd b/dev-libs/libcgroup/files/cgred.initd
deleted file mode 100644
index d507e09a8154..000000000000
--- a/dev-libs/libcgroup/files/cgred.initd
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/sbin/openrc-run
-#
-# CGroups Rules Engine Daemon
-#
-# This is a daemon for automatically classifying processes into cgroups based
-# on UID/GID.
-#
-opts="${opts} reload"
-
-CGRULESENGD="/usr/sbin/cgrulesengd"
-PID_FILE=${PID_FILE:-"/var/run/cgred.pid"}
-
-depend() {
- need cgconfig
- use logger
-}
-
-start() {
- local options="${NODAEMON} ${LOG}"
- if [[ -n "${LOG_FILE}" ]]; then
- options="${options} --log-file=${LOG_FILE}"
- fi
-
- ebegin "Starting CGroup Rules Engine Daemon"
- start-stop-daemon --start --pidfile "${PID_FILE}" --make-pidfile \
- --background --exec "${CGRULESENGD}" -- ${options} >/dev/null
- eend $?
-}
-
-stop() {
- ebegin "Stopping CGroup Rules Engine Daemon"
- start-stop-daemon --stop --pidfile "${PID_FILE}" --exec "${CGRULESENGD}"
- eend $?
-}
-
-reload() {
- ebegin "Reloading CGroup Rules Engine Daemon"
- start-stop-daemon --stop --signal USR2 --oknodo --background \
- --pidfile "${PID_FILE}" --make-pidfile --exec "${CGRULESENGD}"
- eend $?
-}
diff --git a/dev-libs/libcgroup/files/cgrules.service b/dev-libs/libcgroup/files/cgrules.service
new file mode 100644
index 000000000000..2c6426bf9520
--- /dev/null
+++ b/dev-libs/libcgroup/files/cgrules.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=Control Group rules service
+
+# The service should be able to start as soon as possible,
+# before any 'normal' services:
+DefaultDependencies=no
+Conflicts=shutdown.target
+Before=basic.target shutdown.target
+After=cgconfig.service
+
+[Service]
+Type=simple
+ExecStart=/usr/sbin/cgrulesengd -n -f -
+
+[Install]
+WantedBy=sysinit.target