title: init script process pid not working
body: <p>So I have red5 streaming server installed and can get it to launch and stay launched when closing ssh terminal window using the following init.d script code:</p>
  
  <pre><code>#!/bin/bash
  # For RedHat and cousins:
  # chkconfig: 2345 85 85
  # description: Red5 flash streaming server
  # processname: red5
  # Created By: Sohail Riaz (sohaileo@gmail.com)
  
  PROG=red5
  RED5_HOME=/usr/local/red5
  DAEMON=$RED5_HOME/$PROG.sh
  PIDFILE=/var/run/$PROG.pid
  
  # Source function library
  . /etc/rc.d/init.d/functions
  
  [ -r /etc/sysconfig/red5 ] &amp;&amp; . /etc/sysconfig/red5
  
  RETVAL=0
  
  case "$1" in
      start)
      echo -n $"Starting $PROG: "
      cd $RED5_HOME
      $DAEMON &gt;/dev/null 2&gt;/dev/null &amp;
      RETVAL=$?
      if [ $RETVAL -eq 0 ]; then
          echo $! &gt; $PIDFILE
          touch /var/lock/subsys/$PROG
      fi
      [ $RETVAL -eq 0 ] &amp;&amp; success $"$PROG startup" || failure $"$PROG startup"
      echo
      ;;
      stop)
      echo -n $"Shutting down $PROG: "
      killproc -p $PIDFILE
      RETVAL=$?
      echo
      [ $RETVAL -eq 0 ] &amp;&amp; rm -f /var/lock/subsys/$PROG
      ;;
      restart)
      $0 stop
      $0 start
      ;;
      status)
      status $PROG -p $PIDFILE
      RETVAL=$?
      ;;
      *)
      echo $"Usage: $0 {start|stop|restart|status}"
      RETVAL=1
  esac
  
  exit $RETVAL
  </code></pre>
  
  <p>So I can just type 'red5 start', 'red5 status' and 'red5 stop'.</p>
  
  <p>Now I renamed the red5 folder to red5bak and have been testing a new updated version in a new 'red5' folder which also uses a red5.sh file to launch. I can launch this manually no problem and works as intended however when launched with the above commands and code it says started 'OK' but appears not to and when using 'status' command I get the error <code>red5 dead but pid file exists</code>.</p>
  
  <p>I tried deleting the pid red5 files in var/run and lock folders and restarting server but still get the same issue.</p>
  
  <p>If I delete the newer red5 folder and rename the old folder back then the script works again so how can I get it to work for the newer version/files?</p>
  
  <p>Any help would be appreciated,</p>
  
  <p>Thanks.</p>