Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have written several upstart scripts to start transmission-daemon for several users. The script is this:

start on (local-filesystems and net-device-up IFACE=eth0 and runlevel [235])
stop on runlevel [016]

kill timeout 50

respawn

env USER=user
env PIDFILE=/var/run/transmission-user.pid

script
    DAEMON=$(which transmission-daemon) || exit 0
    CONFIGDIR=/home/$USER/.config/transmission-daemon

    exec start-stop-daemon --start --quiet --chuid $USER --pidfile $PIDFILE --make-pidfile --exec $DAEMON -- -f --config-dir $CONFIGDIR --logfile $CONFIGDIR/daemon.log
end script

post-stop exec rm -f $PIDFILE

I would convert this:

env USER=user
env PIDFILE=/var/run/transmission-user.pid

To this:

env USER=user
env PIDFILE=/var/run/transmission-$USER.pid

But upstart doesn't allow. I can do it if I move those lines to the script section:

script
    USER=user
    PIDFILE=/var/run/transmission-$USER.pid
    ...
end script

But in this case, the PIDFILE, in post-stop section, is empty.
Is there any way to do this?

share|improve this question

1 Answer 1

This is a fairly old bug in upstart:

https://bugs.launchpad.net/upstart/+bug/328366

To get the variable in post-stop and script... you'll just have to set it both times to work around the bug.

share|improve this answer

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.