3 # cgred CGroups Rules Engine Daemon
4 # chkconfig: 2345 14 86
5 # description: This is a daemon for automatically classifying processes \
6 # into cgroups based on UID/GID.
8 # processname: cgrulesengd
9 # pidfile: /var/run/cgred.pid
12 # Source function library
13 . /etc/rc.d/init.d/functions
16 if [ -f "/var/lock/subsys/cgred" ] ; then
17 msg_already_running "CGroup Rules Engine Daemon"
21 if [ ! -s /etc/cgrules.conf ]; then
22 nls "CGroup Rules Engine Daemon not configured"
25 if ! grep -qs "^cgroup" /proc/mounts ; then
26 nls "Cannot find cgroups, is cgconfig service running?"
29 msg_staring "CGroup Rules Engine Daemon"
30 # Read in configuration options.
32 if [ -f "/etc/sysconfig/cgred.conf" ] ; then
33 . /etc/sysconfig/cgred.conf
35 OPTIONS="$NODAEMON $LOG"
36 [ -n "$LOG_FILE" ] && OPTIONS="$OPTIONS --logfile=$LOG_FILE"
37 [ -n "$SOCKET_USER" ] && OPTIONS="$OPTIONS -u $SOCKET_USER"
38 [ -n "$SOCKET_GROUP" ] && OPTIONS="$OPTIONS -g $SOCKET_GROUP"
41 daemon --check cgred --pidfile /var/run/cgred.pid /sbin/cgrulesengd $OPTIONS
43 if [ $RETVAL -ne 0 ]; then
46 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/cgred
47 echo "`pidof cgrulesengd`" > /var/run/cgred.pid
51 if [ -f /var/lock/subsys/cgred ]; then
52 msg_stopping "CGroup Rules Engine Daemon"
53 killproc -p /var/run/cgred.pid cgrulesengd -TERM
55 if [ $RETVAL -eq 0 ] ; then
56 rm -f /var/lock/subsys/cgred
57 rm -f /var/run/cgred.pid
60 msg_not_running "CGroup Rules Engine Daemon"
65 # See how we are called
76 status -p /var/run/cgred.pid cgred
84 if [ -f /var/lock/subsys/cgred ] ; then
90 if [ -f /var/lock/subsys/cgred ] ; then
91 show "Reloading rules configuration..."
93 kill -s 12 `cat ${pidfile}`
95 if [ $RETVAL -eq 0 ] ; then
101 msg_not_running "cgred"
105 msg_usage "$0 {start|stop|status|restart|condrestart|reload}"