]>
Commit | Line | Data |
---|---|---|
382db189 JR |
1 | #!/bin/sh |
2 | # | |
3 | # cgconfig Control Groups Configuration Startup | |
dcbb2e58 | 4 | # chkconfig: 2345 01 99 |
382db189 JR |
5 | # description: This script runs the cgconfigparser utility to parse and setup \ |
6 | # the control group filesystem. It uses /etc/cgconfig.conf \ | |
7 | # and parses the configuration specified in there. | |
8 | ||
9 | # Source function library | |
10 | . /etc/rc.d/init.d/functions | |
11 | ||
12 | # read the config | |
382db189 JR |
13 | [ -f /etc/sysconfig/cgconfig ] && . /etc/sysconfig/cgconfig |
14 | ||
dbac3405 AM |
15 | mount_cgroup() { |
16 | if [ -n "`grep /sys/fs/cgroup /proc/mounts`" ]; then | |
17 | return 0 | |
18 | fi | |
19 | ||
20 | # kernel provides cgroups? | |
21 | if [ ! -e /proc/cgroups ]; then | |
22 | return 0 | |
23 | fi | |
24 | ||
25 | run_cmd "Mounting /sys/fs/cgroup" mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup | |
26 | } | |
27 | ||
28 | umount_cgroup() { | |
29 | # If /sys/fs/cgroup is not mounted, we don't bother | |
30 | if [ -z "`grep /sys/fs/cgroup /proc/mounts`" ]; then | |
31 | return 0 | |
32 | fi | |
33 | ||
34 | # Don't try to get too smart, just optimistically try to umount all | |
35 | # that we think we mounted | |
36 | run_cmd "Unmounting /sys/fs/cgroup" umount /sys/fs/cgroup | |
37 | return $? | |
38 | } | |
39 | ||
382db189 JR |
40 | start() { |
41 | # Check if the service is already running? | |
42 | if [ -f /var/lock/subsys/cgconfig ]; then | |
43 | msg_already_running "cgconfig" | |
44 | return | |
45 | fi | |
382db189 | 46 | if [ ! -s /etc/cgconfig.conf ]; then |
04ae980e | 47 | nls "/etc/cgconfig.conf is not configured" |
2ba2a72e ER |
48 | RETVAL=6 |
49 | return | |
382db189 | 50 | fi |
dbac3405 | 51 | mount_cgroup |
ffc5c83f JR |
52 | msg_starting "cgconfig"; busy |
53 | local out | |
2ba2a72e | 54 | out=$(/sbin/cgconfigparser -l /etc/cgconfig.conf 2>&1) |
ffc5c83f JR |
55 | RETVAL=$? |
56 | if [ $RETVAL -ne 0 ]; then | |
57 | fail | |
58 | [ "$out" ] && echo >&2 "$out" | |
59 | exit $RETVAL | |
382db189 JR |
60 | fi |
61 | ||
ffc5c83f JR |
62 | RETVAL=$? |
63 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/cgconfig | |
382db189 JR |
64 | ok |
65 | } | |
66 | ||
67 | stop() { | |
2ba2a72e | 68 | if [ ! -f /var/lock/subsys/cgconfig ]; then |
382db189 | 69 | msg_not_running "cgconfig" |
2ba2a72e | 70 | return |
382db189 | 71 | fi |
2ba2a72e ER |
72 | |
73 | msg_stopping "cgconfig" | |
74 | cgclear | |
dbac3405 | 75 | RETVAL=$? |
92816bbf | 76 | cgclear |
2ba2a72e ER |
77 | rm -f /var/lock/subsys/cgconfig |
78 | ok | |
dbac3405 | 79 | umount_cgroup |
382db189 JR |
80 | } |
81 | ||
2ba2a72e ER |
82 | condrestart() { |
83 | if [ ! -f /var/lock/subsys/cgconfig ]; then | |
84 | msg_not_running "cgconfig" | |
85 | RETVAL=$1 | |
86 | return | |
87 | fi | |
382db189 | 88 | |
2ba2a72e ER |
89 | stop |
90 | start | |
91 | } | |
92 | ||
93 | RETVAL=0 | |
382db189 JR |
94 | case "$1" in |
95 | start) | |
96 | start | |
97 | ;; | |
98 | stop) | |
2ba2a72e | 99 | stop |
382db189 | 100 | ;; |
2ba2a72e | 101 | restart) |
382db189 JR |
102 | stop |
103 | start | |
104 | ;; | |
2ba2a72e ER |
105 | try-restart) |
106 | condrestart 0 | |
107 | ;; | |
108 | force-reload) | |
109 | condrestart 7 | |
382db189 JR |
110 | ;; |
111 | status) | |
112 | if [ -f /var/lock/subsys/cgconfig ] ; then | |
113 | echo "Running" | |
114 | exit 0 | |
115 | else | |
116 | echo "Stopped" | |
117 | exit 3 | |
118 | fi | |
119 | ;; | |
120 | *) | |
2ba2a72e | 121 | msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}" |
382db189 JR |
122 | exit 3 |
123 | ;; | |
124 | esac | |
125 | ||
126 | exit $RETVAL |