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 <jsafrane@redhat.com>
Signed-off-by: Balbir Singh <balbir@linux.vnet.ibm.com>
. /etc/sysconfig/cgconfig
fi
+RETVAL=0
+
create_default_groups() {
declare defaultcgroup
if [ -f /var/lock/subsys/$servicename ]
then
log_warning_msg "lock file already exists"
- return
+ return 0
fi
if [ $? -eq 0 ]
if [ $retval -ne 0 ]
then
log_failure_msg "Failed to parse " $CONFIG_FILE
- return $retval
+ return 1
fi
fi
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
cgclear
rm -f /var/lock/subsys/$servicename
log_success_msg
+ return 0
}
trapped() {
usage() {
echo "$0 <start|stop|restart|condrestart|status>"
- exit 1
+ exit 2
}
common() {
'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')
usage
;;
esac
+
+exit $RETVAL
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
+ RETVAL=2
;;
esac