Hey, I have this problem, that scripts started at boot time from rc.local don't have environment variables (defined at /etc/profile.d/*) set at the time of their startup. What should I do ?
"su - lisak -c /opt/atlassian-jira-enterprise-4.1.1-standalone/bin/startup.sh"
"su - lisak -c /opt/aaa2/at-22/bin/startup.sh"
The scripts at/etc/profile.d/*
are executed in their own shells rather than sourced so the environment variables they set are not available anyway.What variables do you need? Can you make use of/etc/environment
? Can you write the variables into a file in avar=value
format from the appropriate scripts and source that file in yourrc.local
scripts?This is from the Bash man page. You may find it helpful.
The Bourne shell similarly uses the
ENV
variable.Quote from the su manpage (Slackware 13.1):
In your example, you don't specify - as the last su option. Try doing that or using an alternate argument.
I think the best solution is to source /etc/profile.d/*.sh or run /etc/profile from rc.local cause I don't want to duplicate configuration for boot time scripts and scripts started from login shell...
NOTE: I don't know what might be the consequences of running /etc/profile from rc.local ...so the best way would be sourcing them at rc.local from /etc/profile.d/*.sh
AKA: for file in /etc/profile.d/*; do source $file; done
ALTERNATIVE: echo ". /etc/profile" >> $HOME/.bashrc - for single user