Index: init.d/cgconfig.in
===================================================================
--- init.d/cgconfig.in (nonexistent)
+++ init.d/cgconfig.in (revision 5)
@@ -0,0 +1,199 @@
+#!/bin/bash
+#
+# Start/Stop the workload manager
+#
+# Copyright IBM Corporation. 2008
+#
+# Authors: Balbir Singh <balbir@linux.vnet.ibm.com>
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of version 2.1 of the GNU Lesser General Public License
+# as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# cgconfig Control Groups Configuration Startup
+# chkconfig: - 5 95
+# description: This script runs the cgconfigparser utility to parse and setup
+# the control group filesystem. It uses /etc/cgconfig.conf
+# and parses the configuration specified in there.
+
+### BEGIN INIT INFO
+# Provides: cgconfig
+# Required-Start:
+# Required-Stop:
+# Should-Start: ypbind
+# Should-Stop: ypbind
+# Short-Description: Create and setup control group filesystem(s)
+# Description: Create and setup control group filesystem(s)
+### END INIT INFO
+
+# get correct location of binaries from configure
+prefix=@prefix@;exec_prefix=@exec_prefix@;sbindir=@sbindir@
+CGCONFIGPARSER_BIN=$sbindir/cgconfigparser
+CONFIG_FILE=/etc/cgconfig.conf
+servicename=cgconfig
+lockfile=/var/lock/subsys/$servicename
+
+# read the config
+CREATE_DEFAULT=yes
+if [ -e /etc/sysconfig/cgconfig ]; then
+ . /etc/sysconfig/cgconfig
+fi
+
+create_default_groups() {
+ defaultcgroup=
+
+ if [ -f /etc/cgrules.conf ]; then
+ read user ctrl defaultcgroup <<< \
+ $(grep -m1 '^\*[[:space:]]\+' /etc/cgrules.conf)
+ if [ -n "$defaultcgroup" -a "$defaultcgroup" = "*" ]; then
+ echo "/etc/cgrules.conf incorrect"
+ echo "Overriding it"
+ defaultcgroup=
+ fi
+ fi
+
+ if [ -z $defaultcgroup ]
+ then
+ defaultcgroup=sysdefault/
+ fi
+
+ #
+ # Find all mounted subsystems and create comma-separated list
+ # of controllers.
+ #
+ controllers=`lssubsys 2>/dev/null | tr '\n' ',' | sed s/.$//`
+
+ #
+ # Create the default group, ignore errors when the default group
+ # already exists.
+ #
+ cgcreate -f 664 -d 775 -g $controllers:$defaultcgroup 2>/dev/null
+
+ #
+ # special rule for cpusets
+ #
+ if echo $controllers | grep -q -w cpuset; then
+ cpus=`cgget -nv -r cpuset.cpus /`
+ cgset -r cpuset.cpus=$cpus $defaultcgroup
+ mems=`cgget -nv -r cpuset.mems /`
+ cgset -r cpuset.mems=$mems $defaultcgroup
+ fi
+
+ #
+ # Classify everything to default cgroup. Ignore errors, some processes
+ # may exit after ps is run and before cgclassify moves them.
+ #
+ cgclassify -g $controllers:$defaultcgroup `ps --no-headers -eL o tid` \
+ 2>/dev/null || :
+}
+
+start() {
+ echo -n "Starting cgconfig service: "
+ if [ -f "$lockfile" ]; then
+ echo "lock file already exists"
+ return 0
+ fi
+
+ if [ $? -eq 0 ]; then
+ if [ ! -s $CONFIG_FILE ]; then
+ echo $CONFIG_FILE "is not configured"
+ return 6
+ fi
+
+ $CGCONFIGPARSER_BIN -l $CONFIG_FILE
+ retval=$?
+ if [ $retval -ne 0 ]; then
+ echo "Failed to parse " $CONFIG_FILE
+ return 1
+ fi
+ fi
+
+ if [ $CREATE_DEFAULT = "yes" ]; then
+ create_default_groups
+ fi
+
+ touch "$lockfile"
+ retval=$?
+ if [ $retval -ne 0 ]; then
+ echo "Failed to touch $lockfile"
+ return 1
+ fi
+ return 0
+}
+
+stop() {
+ echo -n "Stopping cgconfig service: "
+ /usr/sbin/cgclear
+ rm -f "$lockfile"
+ return 0
+}
+
+trapped() {
+ #
+ # Do nothing
+ #
+ true
+}
+
+usage() {
+ echo "$0 <start|stop|restart|condrestart|status>"
+ exit 2
+}
+
+common() {
+ #
+ # main script work done here
+ #
+ trap "trapped ABRT" ABRT
+ trap "trapped QUIT" QUIT
+ trap "trapped TERM" TERM
+ trap "trapped INT" INT
+}
+
+restart() {
+ common
+ stop
+ start
+}
+
+RETVAL=0
+
+case $1 in
+ 'stop')
+ common
+ stop
+ RETVAL=$?
+ ;;
+ 'start')
+ common
+ start
+ RETVAL=$?
+ ;;
+ 'restart'|'reload')
+ restart
+ RETVAL=$?
+ ;;
+ 'condrestart')
+ if [ -f "$lockfile" ]; then
+ restart
+ RETVAL=$?
+ fi
+ ;;
+ 'status')
+ if [ -f "$lockfile" ]; then
+ echo "Running"
+ exit 0
+ else
+ echo "Stopped"
+ exit 3
+ fi
+ ;;
+ *)
+ usage
+ ;;
+esac
+
+exit $RETVAL
Index: init.d/cgred.in
===================================================================
--- init.d/cgred.in (nonexistent)
+++ init.d/cgred.in (revision 5)
@@ -0,0 +1,154 @@
+#!/bin/bash
+#
+# Start/Stop the CGroups Rules Engine Daemon
+#
+# Copyright Red Hat Inc. 2008
+#
+# Authors: Steve Olivieri <sjo@redhat.com>
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of version 2.1 of the GNU Lesser General Public License
+# as published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# cgred CGroups Rules Engine Daemon
+# chkconfig: - 14 86
+# description: This is a daemon for automatically classifying processes \
+# into cgroups based on UID/GID.
+#
+# processname: cgrulesengd
+# pidfile: /var/run/cgred.pid
+#
+### BEGIN INIT INFO
+# Provides: cgrulesengd
+# Required-Start: $local_fs $syslog $cgconfig
+# Required-Stop: $local_fs $syslog
+# Should-Start:
+# Should-Stop:
+# Short-Description: start and stop the cgroups rules engine daemon
+# Description: CGroup Rules Engine is a tool for automatically using \
+# cgroups to classify processes
+### END INIT INFO
+
+prefix=@prefix@;exec_prefix=@exec_prefix@;sbindir=@sbindir@
+CGRED_BIN=$sbindir/cgrulesengd
+CGRED_CONF=/etc/cgrules.conf
+
+# Sanity checks
+[ -x $CGRED_BIN ] || exit 1
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Read in configuration options.
+if [ -f "/etc/cgred.conf" ] ; then
+ . /etc/cgred.conf
+ OPTIONS="$NODAEMON $LOG"
+ if [ -n "$LOG_FILE" ]; then
+ OPTIONS="$OPTIONS --logfile=$LOG_FILE"
+ fi
+ if [ -n "$SOCKET_USER" ]; then
+ OPTIONS="$OPTIONS -u $SOCKET_USER"
+ fi
+ if [ -n "$SOCKET_GROUP" ]; then
+ OPTIONS="$OPTIONS -g $SOCKET_GROUP"
+ fi
+else
+ OPTIONS=""
+fi
+
+# For convenience
+processname=cgrulesengd
+servicename=cgred
+lockfile="/var/lock/subsys/$servicename"
+pidfile=/var/run/cgred.pid
+
+start()
+{
+ echo -n $"Starting CGroup Rules Engine Daemon: "
+ if [ -f "$lockfile" ]; then
+ echo "$servicename is already running with PID `cat ${pidfile}`"
+ return 0
+ fi
+ num=`grep "cgroup" /proc/mounts | awk '$3=="cgroup"' | wc -l`
+ if [ $num -eq 0 ]; then
+ echo
+ echo $"Cannot find cgroups, is cgconfig service running?"
+ return 1
+ fi
+ daemon --check $servicename --pidfile $pidfile $CGRED_BIN $OPTIONS
+ retval=$?
+ echo
+ if [ $retval -ne 0 ]; then
+ return 7
+ fi
+ touch "$lockfile"
+ if [ $? -ne 0 ]; then
+ return 1
+ fi
+ echo "`pidof $processname`" > $pidfile
+ return 0
+}
+
+stop()
+{
+ echo -n $"Stopping CGroup Rules Engine Daemon..."
+ if [ ! -f $pidfile ]; then
+ return 0
+ fi
+ killproc -p $pidfile -TERM "$processname"
+ retval=$?
+ echo
+ if [ $retval -ne 0 ]; then
+ return 1
+ fi
+ rm -f "$lockfile" "$pidfile"
+ return 0
+}
+
+RETVAL=0
+
+# See how we are called
+case "$1" in
+ start)
+ start
+ RETVAL=$?
+ ;;
+ stop)
+ stop
+ RETVAL=$?
+ ;;
+ status)
+ status -p $pidfile $servicename
+ RETVAL=$?
+ ;;
+ restart)
+ stop
+ start
+ RETVAL=$?
+ ;;
+ condrestart)
+ if [ -f "$lockfile" ]; then
+ stop
+ start
+ RETVAL=$?
+ fi
+ ;;
+ reload|flash)
+ if [ -f "$lockfile" ]; then
+ echo $"Reloading rules configuration..."
+ kill -s 12 `cat ${pidfile}`
+ RETVAL=$?
+ else
+ echo "$servicename is not running."
+ fi
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
+ RETVAL=2
+ ;;
+esac
+
+exit $RETVAL
Index: init.d
===================================================================
--- init.d (nonexistent)
+++ init.d (revision 5)
Property changes on: init.d
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: .
===================================================================
--- . (nonexistent)
+++ . (revision 5)
Property changes on: .
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~