How to concatenate two string environment /w env stanza in Upstart? -


here part of .conf file.

env service_root="/data/service_root" env log_dir="$service_root/logs" 

and checked variables following..

echo "\n`env`" >> /tmp/listener.log 2>&1 

i expect $log_dir "/data/service_root/logs" got is..

service_root=/data/service_root log_dir=$service_root/logs 

did miss something?

defined environment variable not accessible job configuration file itself.

upstart allows set environment variables will accessible jobs job configuration files defined in.

as explained in 8.2 environment variables:

note job configuration file not have access user's environment variables, not superuser. not possible since job processes created children of init not have user's environment.

defined variable $service_root accessible defined job.

# /etc/init/test.conf env service_root="/data/service_root"  script   export log_dir="$service_root/logs"   # prints "log_dir='/data/service_root/logs'" system log   logger -t $0 "log_dir='$log_dir'"   exec /home/vagrant/test.sh >> /tmp/test.log end script 

variable $log_dir exported in script block available processes called within same block.

#!/bin/bash -e # /home/vagrant/test.sh echo "running test.sh" echo "\n`env`" | grep 'log_dir\|service_root' 

after running sudo start test content of /tmp/test.log be:

running test.sh service_root=/data/service_root log_dir=/data/service_root/logs 

in syslog find:

jul 16 01:39:39 vagrant-ubuntu-raring-64 /proc/self/fd/9: log_dir='/data/service_root/logs'


Comments