|
|
5d759f7 |
Bug 619091 - cgconfig service is always reported as "running"
|
|
|
5d759f7 |
|
|
|
5d759f7 |
commit 023fee998f07499938830a044845eb03b816eea7
|
|
|
5d759f7 |
Author: Ivana Hutarova Varekova <varekova@redhat.com>
|
|
|
5d759f7 |
Date: Wed Jul 14 14:30:48 2010 +0200
|
|
|
5d759f7 |
|
|
|
5d759f7 |
Init scripts patch
|
|
|
5d759f7 |
|
|
|
5d759f7 |
This patch fixes the return values to meet the standarts.
|
|
|
5d759f7 |
|
|
|
5d759f7 |
changed values are:
|
|
|
5d759f7 |
cgconfig:
|
|
|
5d759f7 |
* start action: 6: program is not configured
|
|
|
5d759f7 |
* status action: 3: program is not running
|
|
|
5d759f7 |
|
|
|
5d759f7 |
cgred:
|
|
|
5d759f7 |
* start action: 7: program is not running
|
|
|
5d759f7 |
* start action: 6: program is not configured
|
|
|
5d759f7 |
* status action: 3: program is not running
|
|
|
5d759f7 |
* status action: 2: program is dead and /var/run pid file exists
|
|
|
5d759f7 |
* stop action: 0: if the service is not running
|
|
|
5d759f7 |
|
|
|
5d759f7 |
Signed-off-by: Ivana Hutarova Varekova <varekova@redhat.com>
|
|
|
5d759f7 |
Signed-off-by: Dhaval Giani <dhaval.giani@gmail.com>
|
|
|
5d759f7 |
|
|
|
5d759f7 |
diff --git a/scripts/init.d/cgconfig.in b/scripts/init.d/cgconfig.in
|
|
|
5d759f7 |
index 9cf2c9a..d716b40 100644
|
|
|
5d759f7 |
--- a/scripts/init.d/cgconfig.in
|
|
|
5d759f7 |
+++ b/scripts/init.d/cgconfig.in
|
|
|
5d759f7 |
@@ -112,6 +112,12 @@ start() {
|
|
|
5d759f7 |
|
|
|
5d759f7 |
if [ $? -eq 0 ]
|
|
|
5d759f7 |
then
|
|
|
5d759f7 |
+ if [ ! -s $CONFIG_FILE ]
|
|
|
5d759f7 |
+ then
|
|
|
5d759f7 |
+ log_failure_msg $CONFIG_FILE "is not configured"
|
|
|
5d759f7 |
+ return 6
|
|
|
5d759f7 |
+ fi
|
|
|
5d759f7 |
+
|
|
|
5d759f7 |
$CGCONFIGPARSER_BIN -l $CONFIG_FILE
|
|
|
5d759f7 |
retval=$?
|
|
|
5d759f7 |
if [ $retval -ne 0 ]
|
|
|
5d759f7 |
@@ -193,8 +199,10 @@ case $1 in
|
|
|
5d759f7 |
'status')
|
|
|
5d759f7 |
if [ -f /var/lock/subsys/$servicename ] ; then
|
|
|
5d759f7 |
echo "Running"
|
|
|
5d759f7 |
+ exit 0
|
|
|
5d759f7 |
else
|
|
|
5d759f7 |
echo "Stopped"
|
|
|
5d759f7 |
+ exit 3
|
|
|
5d759f7 |
fi
|
|
|
5d759f7 |
;;
|
|
|
5d759f7 |
*)
|
|
|
5d759f7 |
diff --git a/scripts/init.d/cgred.in b/scripts/init.d/cgred.in
|
|
|
5d759f7 |
index db9c2ac..c5b0ed5 100644
|
|
|
5d759f7 |
--- a/scripts/init.d/cgred.in
|
|
|
5d759f7 |
+++ b/scripts/init.d/cgred.in
|
|
|
5d759f7 |
@@ -34,6 +34,7 @@
|
|
|
5d759f7 |
|
|
|
5d759f7 |
prefix=@prefix@;exec_prefix=@exec_prefix@;sbindir=@sbindir@
|
|
|
5d759f7 |
CGRED_BIN=$sbindir/cgrulesengd
|
|
|
5d759f7 |
+CGRED_CONF=/etc/cgrules.conf
|
|
|
5d759f7 |
|
|
|
5d759f7 |
# Sanity checks
|
|
|
5d759f7 |
[ -x $CGRED_BIN ] || exit 1
|
|
|
5d759f7 |
@@ -62,14 +63,21 @@ RETVAL=0
|
|
|
5d759f7 |
|
|
|
5d759f7 |
start()
|
|
|
5d759f7 |
{
|
|
|
5d759f7 |
- echo $"Starting CGroup Rules Engine Daemon..."
|
|
|
5d759f7 |
+ echo -n $"Starting CGroup Rules Engine Daemon: "
|
|
|
5d759f7 |
if [ -f "/var/lock/subsys/$servicename" ] ; then
|
|
|
5d759f7 |
log_failure_msg "$servicename is already running with PID `cat ${pidfile}`"
|
|
|
5d759f7 |
- return 1
|
|
|
5d759f7 |
+ return 0
|
|
|
5d759f7 |
+ fi
|
|
|
5d759f7 |
+ if [ ! -s $CGRED_CONF ]; then
|
|
|
5d759f7 |
+ log_failure_msg "not configured"
|
|
|
5d759f7 |
+ return 6
|
|
|
5d759f7 |
fi
|
|
|
5d759f7 |
daemon --check $servicename --pidfile $pidfile $CGRED_BIN $OPTIONS
|
|
|
5d759f7 |
RETVAL=$?
|
|
|
5d759f7 |
echo
|
|
|
5d759f7 |
+ if [ $RETVAL -ne 0 ]; then
|
|
|
5d759f7 |
+ return 7
|
|
|
5d759f7 |
+ fi
|
|
|
5d759f7 |
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename
|
|
|
5d759f7 |
echo "`pidof $processname`" > $pidfile
|
|
|
5d759f7 |
}
|
|
|
5d759f7 |
@@ -77,6 +85,10 @@ start()
|
|
|
5d759f7 |
stop()
|
|
|
5d759f7 |
{
|
|
|
5d759f7 |
echo -n $"Stopping CGroup Rules Engine Daemon..."
|
|
|
5d759f7 |
+ if [ ! -f $pidfile ]; then
|
|
|
5d759f7 |
+ log_success_msg
|
|
|
5d759f7 |
+ return 0
|
|
|
5d759f7 |
+ fi
|
|
|
5d759f7 |
killproc -p $pidfile $processname -TERM
|
|
|
5d759f7 |
RETVAL=$?
|
|
|
5d759f7 |
echo
|
|
|
5d759f7 |
@@ -84,19 +96,20 @@ stop()
|
|
|
5d759f7 |
rm -f /var/lock/subsys/$servicename
|
|
|
5d759f7 |
rm -f $pidfile
|
|
|
5d759f7 |
fi
|
|
|
5d759f7 |
- log_success_msg
|
|
|
5d759f7 |
}
|
|
|
5d759f7 |
|
|
|
5d759f7 |
# See how we are called
|
|
|
5d759f7 |
case "$1" in
|
|
|
5d759f7 |
start)
|
|
|
5d759f7 |
start
|
|
|
5d759f7 |
+ RETVAL=$?
|
|
|
5d759f7 |
;;
|
|
|
5d759f7 |
stop)
|
|
|
5d759f7 |
stop
|
|
|
5d759f7 |
+ RETVAL=$?
|
|
|
5d759f7 |
;;
|
|
|
5d759f7 |
status)
|
|
|
5d759f7 |
- status -p $pidfile $processname
|
|
|
5d759f7 |
+ status -p $pidfile $servicename
|
|
|
5d759f7 |
RETVAL=$?
|
|
|
5d759f7 |
;;
|
|
|
5d759f7 |
restart)
|