Rev 8 | Blame | Compare with Previous | Last modification | View Log | RSS feed
#!/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: - 28 72# 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 configureprefix=/usr;exec_prefix=/usr;sbindir=/sbinCGCONFIGPARSER_BIN=$sbindir/cgconfigparserCONFIG_FILE=/etc/cgconfig.confCONFIG_DIR=/etc/cgconfig.dservicename=cgconfiglockfile=/var/lock/subsys/$servicename## Source LSB routines#. /etc/rc.d/init.d/functionslog_success_msg () {echo -n $*; success "$*"; echo}log_failure_msg () {echo -n $*; failure "$*"; echo}log_warning_msg () {echo -n $*; warning "$*"; echo}# read the configCREATE_DEFAULT=yesif [ -e /etc/sysconfig/cgconfig ]; then. /etc/sysconfig/cgconfigficreate_default_groups() {defaultcgroup=if [ -f /etc/cgrules.conf ]; thenread user ctrl defaultcgroup <<< \$(grep -m1 '^\*[[:space:]]\+' /etc/cgrules.conf)if [ -n "$defaultcgroup" -a "$defaultcgroup" = "*" ]; thenlog_warning_msg "/etc/cgrules.conf incorrect"log_warning_msg "Overriding it"defaultcgroup=fifiif [ -z $defaultcgroup ]thendefaultcgroup=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; thencpus=`cgget -nv -r cpuset.cpus /`cgset -r cpuset.cpus=$cpus $defaultcgroupmems=`cgget -nv -r cpuset.mems /`cgset -r cpuset.mems=$mems $defaultcgroupfi## 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" ]; thenlog_warning_msg "lock file already exists"return 0fiif [ $? -eq 0 ]; thenif [ ! -s $CONFIG_FILE ]; thenlog_failure_msg $CONFIG_FILE "is not configured"return 6fi$CGCONFIGPARSER_BIN -l $CONFIG_FILE -L $CONFIG_DIRretval=$?if [ $retval -ne 0 ]; thenlog_failure_msg "Failed to parse " $CONFIG_FILE " or " $CONFIG_DIRreturn 1fifiif [ $CREATE_DEFAULT = "yes" ]; thencreate_default_groupsfitouch "$lockfile"retval=$?if [ $retval -ne 0 ]; thenlog_failure_msg "Failed to touch $lockfile"return 1filog_success_msgreturn 0}stop() {echo -n "Stopping cgconfig service: "cgclearrm -f "$lockfile"log_success_msgreturn 0}trapped() {## Do nothing#true}usage() {echo "$0 <start|stop|restart|condrestart|status>"exit 2}common() {## main script work done here#trap "trapped ABRT" ABRTtrap "trapped QUIT" QUITtrap "trapped TERM" TERMtrap "trapped INT" INT}restart() {commonstopstart}RETVAL=0case $1 in'stop')commonstopRETVAL=$?;;'start')commonstartRETVAL=$?;;'restart'|'reload')restartRETVAL=$?;;'condrestart')if [ -f "$lockfile" ]; thenrestartRETVAL=$?fi;;'status')if [ -f "$lockfile" ]; thenecho "Running"exit 0elseecho "Stopped"exit 3fi;;*)usage;;esacexit $RETVAL