title: Bash script for starting jenkins node don't start as linux service in CentOS when it's boot up
body: <p>i was written bash script which will start slave.jar process and vm will appear in jenkins. I have to start this script as service when linux boot up. I place my file in etc/init.d, with chmod +x and after that make chckconfig on it and all links are appears in rc.d folders, output of chkconfig shows:</p>
  
  <pre><code> jenkins-slave   0:off   1:off   2:on    3:on    4:on    5:on    6:off
  </code></pre>
  
  <p>When i make reboot nothing happend, when i run via sudo service jenkins-slave start everything is ok. All propertis contains in another file, everything is working when make it by hands in open session.  How to make it auto executable when CentOs 6 up?</p>
  
  <p>my script: </p>
  
  <pre><code>#!/bin/sh
  #
  # jenkins-slave:    Launch a Jenkins BuildSlave instance on this node
  #
  # chkconfig:    - 99 01
  # description:  Enable this node to fulfill build jobs
  #
  
  # Source function library.
  . /etc/rc.d/init.d/functions
  
  [ -f /etc/sysconfig/jenkins-slave ] &amp;&amp; . /etc/sysconfig/jenkins-slave
  
  [ -n "$JENKINS_URL" ] || exit 0
  [ -n "$JENKINS_WORKDIR" ] || exit 0
  [ -n "$JENKINS_USER" ] || exit 0
  [ -n "$JENKINS_NODENAME" ] || exit 0
  [ -x /usr/bin/java ] || exit 0
  
  download_jar()
  {
  curl -s -o slave.jar $JENKINS_URL/jnlpJars/slave.jar || exit 0
  }
  
  start()
  {
  cd $JENKINS_WORKDIR
  [ -f slave.jar ] || download_jar
  
      echo -n $"Starting Jenkins BuildSlave: "
      su - $JENKINS_USER sh -c "\
    java -jar slave.jar \
           -jnlpUrl $JENKINS_URL/computer/$JENKINS_NODENAME/slave-agent.jnlp \
           &gt;slave.log 2&gt;&amp;1 &amp;"
  
      echo Done.
  }
  
  stop()
  {
      echo -n $"Shutting down Jenkins BuildSlave: "
  killproc slave.jar
  
      echo Done.
  }
  
  # See how we were called.
  case "$1" in
   start)
    start
      ;;
  stop)
   stop
      ;;
  restart|reload)
   stop
    start
  ;;
   status)
    status java
    ;;
   *)
      echo $"Usage: $0 {start|stop|restart|reload}"
      exit 1
   esac
  
    exit 0
  </code></pre>