title: What RETVAL means?
body: <p>I'm trying to create a template for scripts of <code>start</code> and <code>stop</code> services.
  I was checking the template for <code>tomcat</code> start and stop and see the command <code>RETVAL=$?</code>.</p>
  
  <p>What this does ? Should I keep it ?
  By the way, my script it's below in case you guys wanna see it.</p>
  
  <pre><code>#!/bin/bash
  #===================================================================================
  #
  #
  FILE: &lt;script-file-name&gt;.sh
  #
  #
  USAGE: &lt;script-file-name&gt;.sh [-d] [-l] [-oD logfile] [-h] [starting directories]
  #
  # DESCRIPTION: List and/or delete all stale links in directory trees.
  #
  The default starting directory is the current directory.
  #
  Don’t descend directories on other filesystems.
  #
  #
  OPTIONS: see function ’usage’ below
  # REQUIREMENTS: ---
  #
  BUGS: ---
  #
  NOTES: ---
  #
  AUTHOR: Valter Henrique, valter.henrique@&lt;company&gt;.com
  #
  COMPANY: &lt;company&gt;
  #
  VERSION: 1.0
  #
  CREATED: 03.14.13
  #
  REVISION: 03.14.13
  #===================================================================================
  #
  # chkconfig: 345 90 12
  # description: &lt;service-name&gt; start, stop, restart service
  #
  # Get function from functions library
  . /etc/init.d/functions
  
  folder=/&lt;company&gt;/&lt;service-folder&gt; #folder to the application
  service="&lt;service-name&gt;" #name of the service
  
  startup=$folder/start.sh
  shutdown=$folder/stop.sh
  
  
  #=== FUNCTION ================================================================
  #
  NAME: start
  # DESCRIPTION: Start the service &lt;service-name&gt;
  # PARAMETER 1: ---
  #===============================================================================
  start() {
  
    #----------------------------------------------------------------------
    # logging the start
    #----------------------------------------------------------------------
    initlog -c "echo -n Starting $service:"
  
    #----------------------------------------------------------------------
    # getting the process PID
    #----------------------------------------------------------------------    
    pid_process=`ps -ef | grep "$folder/&lt;jar&gt;.jar" | grep -v grep |awk -F' ' '{ print $2 }'`;
  
    if [ $pid_process ]; then
      echo "&lt;service-name&gt; is running!"
      echo "Stop then first!"
    else
      action $"Starting &lt;service-name&gt; service: " su - &lt;user_deployer&gt; -c $startup
      RETVAL=$?
    fi
    #----------------------------------------------------------------------
    # create the lock file
    #----------------------------------------------------------------------
    touch /var/lock/subsys/$service
    success $"Sucess $service startup"
    echo
  }
  
  #=== FUNCTION ================================================================
  #
  NAME: stop
  # DESCRIPTION: Stop the service &lt;service-name&gt;
  # PARAMETER 1: ---
  #===============================================================================
  stop() {
    #----------------------------------------------------------------------
    # logging the stop
    #----------------------------------------------------------------------
    initlog -c "echo -n Stopping $service: "
    killproc $service
    #----------------------------------------------------------------------
    # now, delete the lock file
    #----------------------------------------------------------------------
    rm -f /var/lock/subsys/$service
    echo
  }
  
  #----------------------------------------------------------------------
  # Main Logic
  #----------------------------------------------------------------------
  case "$1" in
    start)
          start
          ;;
    stop)
          stop
          ;;
    status)
          status $service
          ;;
    restart|reload|condrestart)
          stop
          start
          ;;
    *)
          echo $"Usage: $0 {start|stop|restart|reload|status}"
          exit 1
  esac 
  exit 0
  </code></pre>