On 02/28/2011 05:39 PM, Jiri Slaby wrote:
> 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 <jsl...@suse.cz>
Acked-By: Jan Safranek <jsafr...@redhat.com>

> ---
>  scripts/init.d/cgred.in |   28 +++++++++++++++-------------
>  1 files changed, 15 insertions(+), 13 deletions(-)
> 
> diff --git a/scripts/init.d/cgred.in b/scripts/init.d/cgred.in
> index 0bea9e8..9ff2d9b 100644
> --- a/scripts/init.d/cgred.in
> +++ b/scripts/init.d/cgred.in
> @@ -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=$?


------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in 
Real-Time with Splunk. Collect, index and harness all the fast moving IT data 
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business 
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
Libcg-devel mailing list
Libcg-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libcg-devel

Reply via email to