title: bash script starting service over ssh
body: <p>I'm trying to start a service over ssh in a bash script that I just call from the command line. I can do the following commands: (I have ssh keys in place so I don't need to put a p/w in) </p>
  
  <p><code>ssh -t -t user@server 'sudo /sbin/service test stop'</code> -- Works fine, stops the service</p>
  
  <p><code>ssh -t -t user@server 'sudo /sbin/service test status'</code> -- Works fine, status's the service</p>
  
  <p><code>ssh -t -t user@server 'sudo /sbin/service test start'</code> -- Doesn't start the service ???</p>
  
  <p>This is with a custom <code>init.d</code> script running on centos 6.7</p>
  
  <p>Does anyone have any ideas?</p>
  
  <p>or see what I might be missing?</p>
  
  <p>Thanks!</p>
  
  <p>EDIT: Here is the init.d script:</p>
  
  <pre><code>#!/bin/bash
  #
  ### BEGIN INIT INFO
  # Provides:          test
  # Required-Start:    networking
  # Required-Stop:     networking
  # Default-Start:     3 4 5
  # Default-Stop:      0 1 6
  # Short-Description:
  ### END INIT INFO
  #
  
  ###source function library
  source /etc/init.d/functions
  
  APPNAME="test"
  APPDIR="/tmp"
  CONFIGDIR="/tmp/config"
  LOCKFILE=/var/lock/subsys/$APPNAME
  PIDFILE="/var/run/$APPNAME.pid"
  
  ###Declare variables for test
  CONFIG="test.config"
  
  start() {
      echo -n "Starting $APPNAME: "
      source "${CONFIGDIR}/source.txt"
      daemon --pidfile="$PIDFILE" "/tmp/${APPNAME} ${CONFIGDIR}/${CONFIG} &gt;&gt; /tmp/console.log 2&gt;&amp;1 &amp;"
      RETVAL=$?
      [ $RETVAL -eq 0 ] &amp;&amp; {
              touch $LOCKFILE
              pidof $APPNAME &gt; $PIDFILE
      }
      return $RETVAL
  }
  
  stop() {
      echo -n $"Stopping $APPNAME:"
      killproc -p "$PIDFILE" $APPNAME
      RETVAL=$?
      echo
      [ $RETVAL -eq 0 ] &amp;&amp; rm -f $LOCKFILE $PIDFILE
      return $RETVAL
  }
  
  case "$1" in
      start)
              start
              ;;
      stop)
              stop
              ;;
      status)
              status -p "$PIDFILE" "$APPNAME"
              ;;
      restart)
              stop
              start
              ;;
      *)
              echo "Usage $prg {start|stop|status|restart}"
              exit 1
              ;;
  esac
  exit $RETVAL
  </code></pre>