]> git.pld-linux.org Git - packages/libcgroup.git/blob - cgconfig.init
- 0.38.rc1
[packages/libcgroup.git] / cgconfig.init
1 #!/bin/sh
2 #
3 # cgconfig      Control Groups Configuration Startup
4 # chkconfig:    2345 01 99
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
13 [ -f /etc/sysconfig/cgconfig ] && . /etc/sysconfig/cgconfig
14
15 start() {
16         # Check if the service is already running?
17         if [ -f /var/lock/subsys/cgconfig ]; then
18                 msg_already_running "cgconfig"
19                 return
20         fi
21         if [ ! -s /etc/cgconfig.conf ]; then
22                 nls "/etc/cgconfig.conf is not configured"
23                 RETVAL=6
24                 return
25         fi
26         msg_starting "cgconfig"; busy
27         local out
28         out=$(/sbin/cgconfigparser -l /etc/cgconfig.conf 2>&1)
29         RETVAL=$?
30         if [ $RETVAL -ne 0 ]; then
31                 fail
32                 [ "$out" ] && echo >&2 "$out"
33                 exit $RETVAL
34         fi
35
36         RETVAL=$?
37         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/cgconfig
38         ok
39 }
40
41 stop() {
42         if [ ! -f /var/lock/subsys/cgconfig ]; then
43                 msg_not_running "cgconfig"
44                 return
45         fi
46
47         msg_stopping "cgconfig"
48         cgclear
49         cgclear
50         rm -f /var/lock/subsys/cgconfig
51         ok
52 }
53
54 condrestart() {
55         if [ ! -f /var/lock/subsys/cgconfig ]; then
56                 msg_not_running "cgconfig"
57                 RETVAL=$1
58                 return
59         fi
60
61         stop
62         start
63 }
64
65 RETVAL=0
66 case "$1" in
67   start)
68         start
69         ;;
70   stop)
71         stop
72         ;;
73   restart)
74         stop
75         start
76         ;;
77   try-restart)
78         condrestart 0
79         ;;
80   force-reload)
81         condrestart 7
82         ;;
83   status)
84         if [ -f /var/lock/subsys/cgconfig ] ; then
85                 echo "Running"
86                 exit 0
87         else
88                 echo "Stopped"
89                 exit 3
90         fi
91         ;;
92   *)
93         msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
94         exit 3
95         ;;
96 esac
97
98 exit $RETVAL
This page took 0.105979 seconds and 3 git commands to generate.