在upstart脚本中展开变量

我已经写了几个upstart脚本来为几个用户启动transmission-daemon 。 脚本是这样的:

 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 

我会转换这个:

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

对此:

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

但新贵不允许。 如果我将这些行移动到脚本部分,我可以这样做:

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

但在这种情况下,停止后部分的PIDFILE为空。
有没有办法做到这一点?

这是暴发户中相当老的错误:

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

要在后停止和脚本中获取变量…你只需要设置它两次来解决bug。