]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
scripts/init.d: little cleanup cgred.in
authorJiri Slaby <jslaby@suse.cz>
Mon, 28 Feb 2011 16:39:58 +0000 (17:39 +0100)
committerJan Safranek <jsafrane@redhat.com>
Tue, 1 Mar 2011 11:17:36 +0000 (12:17 +0100)
Merge most of suse changes into these scripts to lower the maintanance
burden for us:
* define lockfile and use all over the code
* RETVAL should be used only in the big switch
* use quotes in some places

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Signed-off-by: Jan Safranek <jsafrane@redhat.com>
scripts/init.d/cgred.in

index 0bea9e81ad28660d3c7628be68d7dee2650e4f04..9ff2d9ba06a09f96928454dcec9da6bd6362d8b6 100644 (file)
@@ -63,14 +63,13 @@ fi
 # For convenience
 processname=cgrulesengd
 servicename=cgred
+lockfile="/var/lock/subsys/$servicename"
 pidfile=/var/run/cgred.pid
 
-RETVAL=0
-
 start()
 {
        echo -n $"Starting CGroup Rules Engine Daemon: "
-       if [ -f "/var/lock/subsys/$servicename" ] ; then
+       if [ -f "$lockfile" ]; then
                log_failure_msg "$servicename is already running with PID `cat ${pidfile}`"
                return 0
        fi
@@ -84,12 +83,12 @@ start()
                return 1
        fi
        daemon --check $servicename --pidfile $pidfile $CGRED_BIN $OPTIONS
-       RETVAL=$?
+       retval=$?
        echo
-       if [ $RETVAL -ne 0 ]; then
+       if [ $retval -ne 0 ]; then
                return 7
        fi
-       touch /var/lock/subsys/$servicename
+       touch "$lockfile"
        if [ $? -ne 0 ]; then
                return 1
        fi
@@ -104,17 +103,18 @@ stop()
                log_success_msg
                return 0
        fi
-       killproc -p $pidfile $processname -TERM
-       RETVAL=$?
+       killproc -p $pidfile -TERM "$processname"
+       retval=$?
        echo
-       if [ $RETVAL -ne 0 ] ; then
+       if [ $retval -ne 0 ]; then
                return 1
        fi
-       rm -f /var/lock/subsys/$servicename
-       rm -f $pidfile
+       rm -f "$lockfile" "$pidfile"
        return 0
 }
 
+RETVAL=0
+
 # See how we are called
 case "$1" in
        start)
@@ -132,15 +132,17 @@ case "$1" in
        restart)
                stop
                start
+               RETVAL=$?
                ;;
        condrestart)
-               if [ -f /var/lock/subsys/$servicename ] ; then
+               if [ -f "$lockfile" ]; then
                        stop
                        start
+                       RETVAL=$?
                fi
                ;;
        reload|flash)
-               if [ -f /var/lock/subsys/$servicename ] ; then
+               if [ -f "$lockfile" ]; then
                        echo $"Reloading rules configuration..."
                        kill -s 12 `cat ${pidfile}`
                        RETVAL=$?