File initd_cgred of Package libcgroup1.import4148
#!/bin/bash
#
# Start/Stop the CGroups Rules Engine Daemon
#
# Copyright Red Hat Inc. 2008
#
# Copyright (C) 2008 Jiri Slaby <jslaby@suse.cz>
#
# 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 GGroups Rules Engine Daemon
# chkconfig: 2345 80 20
# description: This is a daemon for automatically classifying processes \
# into cgroups based on UID/GID.
#
### BEGIN INIT INFO
# Provides: cgrulesengd
# Required-Start: $local_fs $remote_fs $syslog cgconfig
# Required-Stop: $local_fs $remote_fs $syslog cgconfig
# Should-Start:
# Should-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# 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
CGRED_BIN=/usr/sbin/cgrulesengd
test -x $CGRED_BIN || exit 5
. /lib/lsb/init-functions
# Read in configuration options.
if [ -f "/etc/sysconfig/cgred" ] ; then
. /etc/sysconfig/cgred
OPTIONS="$NODAEMON $NOLOG"
[ -n $LOG_FILE ] && OPTIONS="$OPTIONS --log $LOG_FILE"
else
OPTIONS="--nolog"
fi
servicename=cgred
lockfile=/var/lock/subsys/cgred
pidfile=/var/run/cgred.pid
start()
{
if [ -f $lockfile ] ; then
pidofproc -k -p $pidfile $CGRED_BIN
if [ $? -eq 7 ]; then
log_warning_msg "Removing stale lock file $lockfile"
rm -f $lockfile
rm -f $pidfile
else
log_failure_msg "$servicename is already running with PID `cat $pidfile`"
return 1
fi
fi
start_daemon -p $pidfile $CGRED_BIN $OPTIONS
retval=$?
if [ $retval -eq 0 ] ; then
touch $lockfile
pidofproc $CGRED_BIN > $pidfile
fi
return $retval
}
stop()
{
killproc -p $pidfile $CGRED_BIN
retval=$?
if [ $retval -eq 0 ] ; then
rm -f $lockfile
rm -f $pidfile
fi
return $retval
}
case "$1" in
start)
echo -n "Starting CGroup Rules Engine Daemon"
start
rc_status -v
;;
stop)
echo -n "Stopping CGroup Rules Engine Daemon"
stop
rc_status -v
;;
status)
echo -n "Checking for CGroup Rules Engine Daemon"
checkproc -k -p $pidfile $CGRED_BIN
if [ $? -eq 7 ] ; then
rc_failed 3
fi
rc_status -v
;;
restart)
stop
start
rc_status
;;
condrestart)
if [ -f $lockfile ] ; then
stop
start
fi
rc_status
;;
reload)
if [ -f $lockfile ] ; then
echo -n "Reloading rules configuration..."
killproc -SIGUSR2 -p $pidfile $CGRED_BIN
else
echo "$servicename is not running."
rc_failed 7
fi
rc_status -v
;;
*)
echo "Usage: $0 {start|stop|status|restart|condrestart|reload}"
exit 1
;;
esac