From be13bad0e41d8debde1e0c3c3345ee1f5158b72f Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Mon, 2 Aug 2010 16:30:45 +0200 Subject: [PATCH] Fix initscript exit codes. Fix initscript exit codes - propagate errors from functions to final exit status - use exit status '1' for generic errors - return status '2' when the service is called with unknown arguments Signed-off-by: Jan Safranek Signed-off-by: Balbir Singh --- scripts/init.d/cgconfig.in | 18 ++++++++++++++---- scripts/init.d/cgred.in | 1 + 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/scripts/init.d/cgconfig.in b/scripts/init.d/cgconfig.in index d716b409..773df8ad 100644 --- a/scripts/init.d/cgconfig.in +++ b/scripts/init.d/cgconfig.in @@ -52,6 +52,8 @@ if [ -e /etc/sysconfig/cgconfig ]; then . /etc/sysconfig/cgconfig fi +RETVAL=0 + create_default_groups() { declare defaultcgroup @@ -107,7 +109,7 @@ start() { if [ -f /var/lock/subsys/$servicename ] then log_warning_msg "lock file already exists" - return + return 0 fi if [ $? -eq 0 ] @@ -123,7 +125,7 @@ start() { if [ $retval -ne 0 ] then log_failure_msg "Failed to parse " $CONFIG_FILE - return $retval + return 1 fi fi @@ -136,7 +138,7 @@ start() { if [ $retval -ne 0 ] then log_failure_msg "Failed to touch " /var/lock/subsys/$servicename - return $retval + return 1 fi log_success_msg return 0 @@ -147,6 +149,7 @@ stop() { cgclear rm -f /var/lock/subsys/$servicename log_success_msg + return 0 } trapped() { @@ -158,7 +161,7 @@ trapped() { usage() { echo "$0 " - exit 1 + exit 2 } common() { @@ -175,25 +178,30 @@ case $1 in 'stop') common stop; + RETVAL=$? ;; 'start') common start; + RETVAL=$? ;; 'restart') common stop start + RETVAL=$? ;; 'reload') common stop start + RETVAL=$? ;; 'condrestart') if [ -f /var/lock/subsys/$servicename ] ; then stop start + RETVAL=$? fi ;; 'status') @@ -209,3 +217,5 @@ case $1 in usage ;; esac + +exit $RETVAL diff --git a/scripts/init.d/cgred.in b/scripts/init.d/cgred.in index c5b0ed52..4cea5a47 100644 --- a/scripts/init.d/cgred.in +++ b/scripts/init.d/cgred.in @@ -138,6 +138,7 @@ case "$1" in ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}" + RETVAL=2 ;; esac -- 2.47.2