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/cgrulesengd.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"
26 if ! grep -qs "^cgroup" /proc/mounts; then
27 nls "Cannot find cgroups, is cgconfig service running?"
32 msg_starting "CGroup Rules Engine Daemon"
33 # Read in configuration options.
35 if [ -f /etc/sysconfig/cgred.conf ]; then
36 . /etc/sysconfig/cgred.conf
38 OPTIONS="$NODAEMON $LOG"
39 [ -n "$LOG_FILE" ] && OPTIONS="$OPTIONS --logfile=$LOG_FILE"
40 [ -n "$SOCKET_USER" ] && OPTIONS="$OPTIONS -u $SOCKET_USER"
41 [ -n "$SOCKET_GROUP" ] && OPTIONS="$OPTIONS -g $SOCKET_GROUP"
44 daemon --pidfile /var/run/cgrulesengd.pid /sbin/cgrulesengd $OPTIONS
46 if [ $RETVAL -ne 0 ]; then
49 touch /var/lock/subsys/cgred
50 pidof cgrulesengd > /var/run/cgrulesengd.pid
54 if [ ! -f /var/lock/subsys/cgred ]; then
55 msg_not_running "CGroup Rules Engine Daemon"
59 msg_stopping "CGroup Rules Engine Daemon"
60 killproc --pidfile /var/run/cgrulesengd.pid cgrulesengd -TERM
62 if [ $RETVAL -eq 0 ] ; then
63 rm -f /var/lock/subsys/cgred /var/run/cgrulesengd.pid
68 if [ ! -f /var/lock/subsys/cgred ] ; then
69 msg_not_running "CGroup Rules Engine Daemon"
73 show "Reloading rules configuration..."
75 kill -s 12 $(cat ${pidfile})
77 if [ $RETVAL -eq 0 ]; then
85 if [ ! -f /var/lock/subsys/cgred ]; then
86 msg_not_running "CGroup Rules Engine Daemon"
96 # See how we are called
118 status --pidfile /var/run/cgrulesengd.pid cgrulesengd
122 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"