Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm trying to get a starter script (for a ruby gem called ar_sendmail) working in /etc/init.d/ar_sendmail:

#! /bin/sh

echo "in /etc/init.d/ar_sendmail"
DIR=/home/max/work/e_learning_resource/trunk
PATH=/var/lib/gems/1.8/bin
DAEMON=/var/lib/gems/1.8/bin/ar_sendmail
DAEMON_OPTS="-e production -d --batch-size 100 --delay 150"
NAME=ar_sendmail
DESC=ar_sendmail
PID_FILE=/home/max/work/e_learning_resource/trunk/shared/log/ar_sendmail.pid


test -x $DAEMON || exit 0
set -e

case "$1" in
  start)
        echo -n "Starting $DESC: "
        start-stop-daemon -d $DIR --start --quiet --pidfile $PID_FILE \
                --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        ;;
  stop)
        echo -n "Stopping $DESC: "
        kill -TERM `cat $PID_FILE`        
    rm $PID_FILE
        echo "$NAME."
        ;;
  restart)
        echo -n "Restarting $DESC: "
        kill -TERM `cat $PID_FILE`        
    rm $PID_FILE
        sleep 1
        start-stop-daemon -d $DIR --start --quiet --pidfile \
                $PID_FILE --exec $DAEMON -- $DAEMON_OPTS
        echo "$NAME."
        ;;
      *)
            N=/etc/init.d/$NAME
            echo "Usage: $N {start|stop|restart|reload}" >&2
            exit 1   
            ;;
    esac

    exit 0

It's blowing up on the start-stop-daemon line, saying "start-stop-daemon: not found". But, when i plug the values into that line manually, and run it on the command line, it works.

My first thought was it was the shebang line but #! /bin/sh should be right shouldn't it? It's definitely the right folder and what i use in my other /etc/init.d scripts.

My second thought was that it's sudo related: i'd been testing start-stop-daemon in non-sudo and running /etc/init.d/ar_sendmail in sudo mode. But, i can run start-stop-daemon fine with sudo as well.

Kind of stumped, any ideas?

share|improve this question
1  
Please don't cross-post. –  Dennis Williamson Mar 8 '11 at 11:40
add comment

1 Answer

PATH=/var/lib/gems/1.8/bin

There's your problem.

You're clobbering your PATH variable so it can't find start-stop-daemon in /sbin

Try using:

PATH=${PATH}:/var/lib/gems/1.8/bin

Or something similar instead.

share|improve this answer
    
aaah! of course. Thanks matt. –  Max Williams Mar 9 '11 at 10:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.