]>
Commit | Line | Data |
---|---|---|
382db189 JR |
1 | #!/bin/sh |
2 | # | |
3 | # cgred CGroups Rules Engine Daemon | |
dcbb2e58 | 4 | # chkconfig: 2345 02 98 |
382db189 JR |
5 | # description: This is a daemon for automatically classifying processes \ |
6 | # into cgroups based on UID/GID. | |
7 | # | |
8 | # processname: cgrulesengd | |
933aa1de | 9 | # pidfile: /var/run/cgrulesengd.pid |
382db189 JR |
10 | # |
11 | ||
12 | # Source function library | |
13 | . /etc/rc.d/init.d/functions | |
14 | ||
9166bcc3 JR |
15 | # Read in configuration options. |
16 | [ -f /etc/sysconfig/cgred ] && . /etc/sysconfig/cgred | |
17 | ||
382db189 | 18 | start() { |
8c6adf20 | 19 | if [ -f /var/lock/subsys/cgred ]; then |
382db189 JR |
20 | msg_already_running "CGroup Rules Engine Daemon" |
21 | return | |
22 | fi | |
23 | ||
382db189 | 24 | if [ ! -s /etc/cgrules.conf ]; then |
04ae980e | 25 | nls "CGroup Rules Engine Daemon not configured" |
8c6adf20 ER |
26 | RETVAL=6 |
27 | return | |
382db189 | 28 | fi |
8c6adf20 | 29 | if ! grep -qs "^cgroup" /proc/mounts; then |
04ae980e | 30 | nls "Cannot find cgroups, is cgconfig service running?" |
8c6adf20 ER |
31 | RETVAL=1 |
32 | return | |
382db189 | 33 | fi |
8c6adf20 | 34 | |
46a5eb94 | 35 | msg_starting "CGroup Rules Engine Daemon" |
382db189 | 36 | |
933aa1de | 37 | daemon --pidfile /var/run/cgrulesengd.pid /sbin/cgrulesengd $OPTIONS |
382db189 JR |
38 | RETVAL=$? |
39 | if [ $RETVAL -ne 0 ]; then | |
40 | return 7 | |
41 | fi | |
7e869c6f | 42 | touch /var/lock/subsys/cgred |
933aa1de | 43 | pidof cgrulesengd > /var/run/cgrulesengd.pid |
382db189 JR |
44 | } |
45 | ||
46 | stop() { | |
8c6adf20 | 47 | if [ ! -f /var/lock/subsys/cgred ]; then |
382db189 | 48 | msg_not_running "CGroup Rules Engine Daemon" |
8c6adf20 ER |
49 | return |
50 | fi | |
51 | ||
52 | msg_stopping "CGroup Rules Engine Daemon" | |
933aa1de | 53 | killproc --pidfile /var/run/cgrulesengd.pid cgrulesengd -TERM |
8c6adf20 | 54 | RETVAL=$? |
bb6b4f05 | 55 | rm -f /var/lock/subsys/cgred /var/run/cgrulesengd.pid |
8c6adf20 ER |
56 | } |
57 | ||
58 | reload() { | |
59 | if [ ! -f /var/lock/subsys/cgred ] ; then | |
933aa1de | 60 | msg_not_running "CGroup Rules Engine Daemon" |
8c6adf20 ER |
61 | return |
62 | fi | |
63 | ||
64 | show "Reloading rules configuration..." | |
65 | # SIGUSR2 | |
66 | kill -s 12 $(cat ${pidfile}) | |
67 | RETVAL=$? | |
68 | if [ $RETVAL -eq 0 ]; then | |
69 | fail | |
70 | else | |
71 | ok | |
72 | fi | |
73 | } | |
74 | ||
75 | condrestart() { | |
76 | if [ ! -f /var/lock/subsys/cgred ]; then | |
933aa1de | 77 | msg_not_running "CGroup Rules Engine Daemon" |
8c6adf20 ER |
78 | RETVAL=$1 |
79 | return | |
382db189 | 80 | fi |
8c6adf20 ER |
81 | |
82 | stop | |
83 | start | |
382db189 JR |
84 | } |
85 | ||
86 | RETVAL=0 | |
87 | # See how we are called | |
88 | case "$1" in | |
89 | start) | |
90 | start | |
382db189 JR |
91 | ;; |
92 | stop) | |
93 | stop | |
382db189 JR |
94 | ;; |
95 | restart) | |
96 | stop | |
97 | start | |
98 | ;; | |
0c043bf5 | 99 | reload) |
8c6adf20 ER |
100 | reload |
101 | ;; | |
102 | try-restart) | |
103 | condrestart 0 | |
104 | ;; | |
105 | force-reload) | |
106 | condrestart 7 | |
107 | ;; | |
108 | status) | |
a5f56916 | 109 | status --pidfile /var/run/cgrulesengd.pid cgrulesengd |
8c6adf20 | 110 | RETVAL=$? |
382db189 JR |
111 | ;; |
112 | *) | |
8c6adf20 | 113 | msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}" |
382db189 JR |
114 | exit 3 |
115 | ;; | |
116 | esac | |
117 | ||
118 | exit $RETVAL |