summaryrefslogtreecommitdiffstats
path: root/scripts/init.d/cgred.in
diff options
context:
space:
mode:
authorJan Safranek <jsafrane@redhat.com>2009-04-14 13:52:47 +0200
committerDhaval Giani <dhaval@linux.vnet.ibm.com>2009-05-08 10:45:25 +0530
commit47045ddcf5e98fec52174fc075a7e61291aeaa75 (patch)
tree7df53b73b8db1e99ed74f7db182859f951cae06a /scripts/init.d/cgred.in
parent8624b3397ff6dbdbfd44dcd6efe8add0492e2d2d (diff)
downloadlibcg-47045ddcf5e98fec52174fc075a7e61291aeaa75.tar.gz
libcg-47045ddcf5e98fec52174fc075a7e61291aeaa75.tar.xz
libcg-47045ddcf5e98fec52174fc075a7e61291aeaa75.zip
Generate paths in initscripts by configure script
Change the hardcoded paths in initscripts to dynamically generated ones. The real executable path $bindir can be constructed using $prefix and $exec_prefix variables, therefore it's necessary to define also these two. The patch includes removal of old initscripts from git - they are generated from .in file now. I did not run autoreconf, I think the generated junk is being removed from git soon. Signed-off-by: Jan Safranek <jsafrane@redhat.com> Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Diffstat (limited to 'scripts/init.d/cgred.in')
-rw-r--r--scripts/init.d/cgred.in131
1 files changed, 131 insertions, 0 deletions
diff --git a/scripts/init.d/cgred.in b/scripts/init.d/cgred.in
new file mode 100644
index 0000000..f539fe7
--- /dev/null
+++ b/scripts/init.d/cgred.in
@@ -0,0 +1,131 @@
+#!/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 GGroups 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@;bindir=@bindir@
+CGRED_BIN=$bindir/cgrulesengd
+
+# Sanity checks
+[ -x $CGRED_BIN ] || exit 1
+
+# Source function library & LSB routines
+. /etc/rc.d/init.d/functions
+. /lib/lsb/init-functions
+
+# Read in configuration options.
+if [ -f "/etc/sysconfig/cgred.conf" ] ; then
+ . /etc/sysconfig/cgred.conf
+ OPTIONS="$NODAEMON $LOG"
+ if [ -n "$LOG_FILE" ]; then
+ OPTIONS="$OPTIONS --log-file=$LOG_FILE"
+ fi
+else
+ OPTIONS=""
+fi
+
+# For convenience
+processname=cgrulesengd
+servicename=cgred
+pidfile=/var/run/cgred.pid
+
+RETVAL=0
+
+start()
+{
+ echo $"Starting CGroup Rules Engine Daemon..."
+ if [ -f "/var/lock/subsys/$servicename" ] ; then
+ log_failure_msg "$servicename is already running with PID `cat ${pidfile}`"
+ return 1
+ fi
+ daemon --check $servicename --pidfile $pidfile $processname $OPTIONS
+ RETVAL=$?
+ echo
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename
+ echo "`pidof $processname`" > $pidfile
+}
+
+stop()
+{
+ echo -n $"Stopping CGroup Rules Engine Daemon..."
+ killproc -p $pidfile $processname -TERM
+ RETVAL=$?
+ echo
+ if [ $RETVAL -eq 0 ] ; then
+ rm -f /var/lock/subsys/$servicename
+ rm -f $pidfile
+ fi
+ log_success_msg
+}
+
+# See how we are called
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ status -p $pidfile $processname
+ RETVAL=$?
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ condrestart)
+ if [ -f /var/lock/subsys/$servicename ] ; then
+ stop
+ start
+ fi
+ ;;
+ reload|flash)
+ if [ -f /var/lock/subsys/$servicename ] ; then
+ echo $"Reloading rules configuration..."
+ kill -s 12 `cat ${pidfile}`
+ RETVAL=$?
+ if [ $RETVAL -eq 0 ] ; then
+ log_success_msg
+ else
+ log_failure_msg
+ fi
+ else
+ log_failure_msg "$servicename is not running."
+ fi
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
+ ;;
+esac
+
+exit $RETVAL